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 trial

WordPress WordPress Theme Development Working with CSS and JS in WordPress Themes How to Link to JS from functions.php File

How 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

I found out why: I was forgetting to use wp_head() and wp_footer()

Kevin Korte
Kevin Korte
28,149 Points

Ah cool, there you go! Good job

can you clarify where you used wp_head() and wp_footer()?

wp_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.

Kevin Korte
Kevin Korte
28,149 Points

First 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.

Thanks Kevin, but how do you troubleshoot in case the files aren't being pulled, but they should be?

Kevin Korte
Kevin Korte
28,149 Points

So 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?