Skip to content

Instantly share code, notes, and snippets.

@PittsburghChris
Forked from studiopress/functions.php
Last active December 29, 2015 00:29
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 PittsburghChris/7586814 to your computer and use it in GitHub Desktop.
Save PittsburghChris/7586814 to your computer and use it in GitHub Desktop.
How to add Google Fonts to an HTML5-compatible Genesis child theme after 2013.
<?php
//* Do NOT include the opening php tag
//* Enqueue Lato Google font
add_action( 'wp_enqueue_scripts', 'sp_load_google_fonts', 5);
function sp_load_google_fonts() {
wp_enqueue_style( 'google-font-lato', '//fonts.googleapis.com/css?family=Lato:300,700', array(), CHILD_THEME_VERSION );
}
@PittsburghChris
Copy link
Author

The above resource is written up at:
http://my.studiopress.com/tutorials/load-google-fonts/

It is compatible with the Genesis HTML5-ready themes.

This should replace Genesis' old "@import" method. That method is explained at:
http://www.studiopress.com/tips/google-web-fonts.htm

It could also replace WPBeginner's "hook" method, explained at:
http://www.wpbeginner.com/wp-themes/how-add-google-web-fonts-wordpress-themes/
add_action( 'genesis_meta', 'wpb_add_google_fonts', 5);
function wpb_add_google_fonts() {
echo '';
}

@PittsburghChris
Copy link
Author

To the StudioPress recommendation: I added the priority "5", as seen in the WPBeginner's demo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment