Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to include a flexslider.css file with this code:

wp_register_style( 'flexslider', get_template_directory_uri() . '/css/flexslider.css' );
if( is_page( 'home' ) ) {
    wp_enqueue_style( 'flexslider' );
}

but it is not working this way, any idea why? trying to solve this one for a whole day.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You need to hook it to an action.

Add the below code to the theme's functions.php file. It should work.

add_action( 'wp_enqueue_scripts', 'theme_flexslider_css' );
function theme_flexslider_css() {
    wp_register_style( 'flexslider', get_template_directory_uri() . '/css/flexslider.css' ); 
    if( is_page( 'home' ) ) { 
        wp_enqueue_style( 'flexslider' ); 
    }
}
share|improve this answer
    
function theme_styles() { wp_register_style( 'flexslider', get_template_directory_uri() . '/css/flexslider.css' ); if( is_page( 'home' ) ) { wp_enqueue_style( 'flexslider' ); } } add_action( 'wp_enqueue_scripts', 'theme_styles', ); still did not work –  Linards Berzins Oct 3 '13 at 19:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.