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 CSS

Emil Wallgren
Emil Wallgren
11,737 Points

FlexSlider won't work

Hi!

The theme styles including the flexslider is written like this ``` 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('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');
}

}    ```

What is wrong? When I inspect the home-page, there is no link to the slider...:-/

/E

5 Answers

Anthony Moore
Anthony Moore
2,282 Points

the 'is_page()' function accepts either the Page ID, Page Title or Page Slug. See http://codex.wordpress.org/Function_Reference/is_page

So 'home' would assume that you have a page called "Home".

Anthony Moore
Anthony Moore
2,282 Points

Instead of using wp_register_style('flexslider', get_template_directory_uri() . '/css/flexslider.css');

try

if( is_page('home') )
 wp_enqueue_style('flexslider', get_template_directory_uri() . '/css/flexslider.css');
Emil Wallgren
Emil Wallgren
11,737 Points

Did not work I'm afraid...what does 'home' stand for in this case? is this some file name?

/E

Emil Wallgren
Emil Wallgren
11,737 Points

Thanks Anthony! :-) You know what the weird thing was? I have a page called Home.... But it only connected if it was is_page('Home')....and not is_page('home')...seems it is very case sensitive

So now it works. Guess what...you just made my friday.

Anthony Moore
Anthony Moore
2,282 Points

It is possible that the page slug for this page is something other than 'home'. But glad you got it working by using the page title!

Cheers.