Skip to content

Instantly share code, notes, and snippets.

@deeman
Last active August 25, 2019 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deeman/a2c44c575f13e23e22ffc98c448240fe to your computer and use it in GitHub Desktop.
Save deeman/a2c44c575f13e23e22ffc98c448240fe to your computer and use it in GitHub Desktop.
How to use Google Fonts in WordPress, the right way
//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');
//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