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 trialMatt Van Dyck
2,033 PointsLinking CSS/Javascript
Hi there. I can't seem to link my flexslider css or js file correctly in the wordpress theme tutorial. Here is the code I have in my functions.php file. I don't know why it isn't linking correctly?
// 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/style.css');
wp_enqueue_style( 'googlefonts', '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_register_style( 'flexslider', get_template_directory_uri() . '/css/flexslider.css');
if( is_page('home')) {
wp_enqueue_style( 'flexslider' );
}
}
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' );
3 Answers
Zac Gordon
Treehouse Guest TeacherHi!
Try changing is_page('home') to is_front_page() and see if that helps.
Matt Van Dyck
2,033 PointsI appreciate your response, that worked perfectly! But I am failing to understand why that worked over the is_page
Zac Gordon
Treehouse Guest TeacherIf your URL slug for is equal to home it will work. If its something like homepage it won't :)
I'm guessing that was the issue.
Luke Lee
7,577 PointsThank you Zac. I had the same problem, How to check the url slug?
Matt Van Dyck
2,033 PointsMatt Van Dyck
2,033 PointsHi there. I actually replaced the functions.php file with the one given in the documentation and my source still does not show the flexslider loading?