0

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.

1 Answer 1

2

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' ); 
    }
}
1
  • 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 Oct 3, 2013 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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