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 How to Build a WordPress Theme Preparing to Code WordPress Templates Linking JavaScript

Kelly Ann Jones
Kelly Ann Jones
1,075 Points

JS not showing up in source

I can't get the js file for flexslider to show up in my source code.

Can someone please take a look and let me know what I'm doing wrong? I've checked it and redone it numerous times.

''' <?php //Load the Theme CSS function theme_styles() {

wp_enqueue_style( 'normalize', get_template_directory_uri() . '/css/normalize.css' );
wp_enqueue_style( 'grid', get_template_directory_uri() . '/css/grid.css' );
wp_enqueue_style( 'google', 'http://fonts.googleapis.com/css?family=Sorts+Mill+Goudy:400,400italic' );
wp_enqueue_style( 'main', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'social', get_template_directory_uri() . '/css/webfonts/ss-social.css' );
wp_enqueue_style( 'flexslider', get_template_directory_uri() . '/css/flexslider.css' );


}   

function theme_js() {

wp_register_script( 'flexslider', get_template_directory_uri() . '/js/flexslider.js', array('jquery'), '', true );
    if( is_page( 'home' ) ) {
        wp_enqueue_script( 'flexslider' );

    }

}

add_action( 'wp_enqueue_scripts', 'theme_js' );

add_action( 'wp_enqueue_scripts', 'theme_styles' );

//Enable custom menus add_theme_support( 'menus' );

?>

'''

Thanks, Kelly

2 Answers

Chris Dziewa
Chris Dziewa
17,781 Points

Is your js file in the correct folder? Is the footer working correctly? Also, is the name of your home page correct (It is case sensitive)?

Kelly Ann Jones
Kelly Ann Jones
1,075 Points

Hi Chris,

Thanks for the response. Yes on all of the above. I finally just removed the if statement and it's fine. I would actually prefer not to limit it anyway. I was only doing it because it was part of the tutorial. I can go back when I'm finished and try and see what I did wrong, but for now it's good.

Thanks again for the response. Kelly

Chris Dziewa
Chris Dziewa
17,781 Points

Anytime, glad you got it working!