Last active
August 25, 2019 09:45
-
-
Save deeman/a2c44c575f13e23e22ffc98c448240fe to your computer and use it in GitHub Desktop.
How to use Google Fonts in WordPress, the right way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Better method regarding to the WordPress Codex | |
//Example | |
function my_google_fonts() { | |
if (!is_admin()) { | |
wp_register_style('google', 'https://fonts.googleapis.com/css?family=Roboto', array(), null, 'all'); | |
wp_enqueue_style('google'); | |
}} | |
add_action('wp_enqueue_scripts', 'my_google_fonts'); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//My previous version | |
function my_google_fonts() { | |
wp_enqueue_style( 'roboto', 'https://fonts.googleapis.com/css?family=Roboto' ); | |
} | |
add_action('wp_enqueue_scripts', 'my_google_fonts'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment