CSS file not registering through add_action

Im having a problem to register and load a gallery css code from my home page. Rest of the styles are loading fine, but this flexslider is not registering. Any guidance appreciated.

<?php 

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 ('main', get_template_directory_uri() . '/style.css');

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' );

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

?>

Related posts

2 comments

  1. The primary issue is an incorrect template conditional tag:

    if( is_page( 'home' ) ) {}
    

    This returns true if the current context is a static page, with the slug home. I presume that you’re actually wanting to test for the Site Front Page – in which case you need to use the is_front_page() conditional:

    if ( is_front_page() ) {
        wp_enqueue_style( 'flexslider' );
    }
    

    If the stylesheet still isn’t being output, we’ll need further debugging information.

  2. Try removing all points of failure and do what you know will work without any question. Then move forward from there one step at a time.

    This is what I would do first just to make sure I am not completely insane!

    <link type="text/css" href="<?php echo get_template_directory_uri(); ?>/css/flexslider.css">
    

    Then if that is outputting then move forward. If not, fairly simple fix at that point. Coding really is full-time trouble shooting. 🙂

Comments are closed.