Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialNijad Kifayeh
6,092 PointsGoogle fonts registration/enqueing problem
For some reason, my google fonts are loading incorrectly in my header....http://localhost/fork/ is being prefixed to the google fonts address and I can't figure out why!.
Here's my functions.php code:
function wpt_theme_styles() {
wp_register_style( 'normalize_css', get_template_directory_uri() . '/css/normalize.css' ) ;
wp_enqueue_style( 'normalize_css', get_template_directory_uri() . '/css/normalize.css' ) ;
wp_register_style( 'googleFonts_css', ' http://fonts.googleapis.com/css?family=Asap:400,700,400italic,700italic' ) ;
wp_enqueue_style( 'googleFonts_css', ' http://fonts.googleapis.com/css?family=Asap:400,700,400italic,700italic' ) ;
wp_register_style( 'foundation_css', get_template_directory_uri() . '/css/foundation.css' ) ;
wp_enqueue_style( 'foundation_css', get_template_directory_uri() . '/css/foundations.css' ) ;
wp_register_style( 'main_css', get_template_directory_uri() . '/style.css' ) ;
wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css' ) ;
}
add_action( 'wp_enqueue_scripts', 'wpt_theme_styles' );
1 Answer
M Fen
9,858 PointsI think this "may" be it.
You're registering with a ulr path and then you're enqueuing with the path. Try taking it out of the enqueue portion and see if that works:
wp_register_style( 'googleFonts_css', ' http://fonts.googleapis.com/css?family=Asap:400,700,400italic,700italic' ) ;
wp_enqueue_style( 'googleFonts_css' ) ;
Nijad Kifayeh
6,092 PointsNijad Kifayeh
6,092 PointsUnfortunately that didn't work....I also tried enqueing w/o first registering (although i kept the URL in the wp_enqueue_style() ) and received the same error; I was able to register w/o enqueing though and I didn't get an error, but naturally the goole fonts did not load...