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 trialDaniele Manca
10,986 PointsHow to troubleshoot why the stylesheets aren't be pulled after uploading the functions.php file with the relevant code?
I have created the functions.php file with the below code, however the styles aren't being pulled on the site I am working on, can anyone help?
<?php
function wpt_theme_styles() {
wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'orbit_css', get_template_directory_uri() . '/css/orbit.css' );
}
add_action( 'wp_enqueue_scripts', 'wpt_theme_styles' );
function wpt_theme_js() {
wp_enqueue_script( 'modernizr_js', get_template_directory_uri() . 'js/modernizr.js', '', '', false );
wp_enqueue_script( 'orbit_js', get_template_directory_uri() . 'js/jquery.orbit-1.2.3.min.js', array('jquery'), '', true );
}
add_action( 'wp_enqueue_scripts', 'wpt_theme_js' );
?>
2 Answers
Daniele Manca
10,986 PointsI found out why: I was forgetting to use wp_head() and wp_footer()
Kevin Korte
28,149 PointsFirst place I start is to look at the source code and find out if it's trying to load the CSS files, but it can't find them in the location it thinks they should be, or they simply just are not showing up in the head.
Daniele Manca
10,986 PointsThanks Kevin, but how do you troubleshoot in case the files aren't being pulled, but they should be?
Kevin Korte
28,149 PointsSo when you inspect the head of your WP site, style.css and css/orbit.css are not even in there? The browser has no mention of them?
Kevin Korte
28,149 PointsKevin Korte
28,149 PointsAh cool, there you go! Good job
Nijad Kifayeh
6,092 PointsNijad Kifayeh
6,092 Pointscan you clarify where you used wp_head() and wp_footer()?
Daniele Manca
10,986 PointsDaniele Manca
10,986 Pointswp_head() needs to be placed into header.php, within the head element, and wp_footer() goes into footer.php, before the end of the body tag.