• The same CSS file is appearing in dev tools twice. The codex warned about this but I can’t see where I’ve gone wrong

    function storefrontchild_enqueue_styles() {
    
        $parent_style = 'storefront-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.
    
        wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
        wp_enqueue_style( 'child-style',
            get_stylesheet_directory_uri() . '/style.css',
            array( $parent_style ),
            wp_get_theme()->get('Version')
        );
    }
    add_action( 'wp_enqueue_scripts', 'storefrontchild_enqueue_styles' );
Viewing 3 replies - 1 through 3 (of 3 total)
  • link?

    Moderator bcworkz

    (@bcworkz)

    As the Codex warned, using the wrong handle can cause this. I’ll assume you’ve double checked this and ‘storefront-style’ is truly the correct handle. Some themes load their stylesheets differently than the normal convention such that WP cannot see that the sheet has already been linked. In such a case, you should then be able to simply comment out the wp_enqueue_style( $parent_style, //... line in your callback. The parent sheet will be loaded with the other parent files.

    Verify the parent sheet is still loaded and your stylesheet is loaded after the parent theme’s. If it is loaded before, your styles will not easily override the parent’s. To cause it to load later, remove the $parent_style from your stylesheet’s dependency array and add a large priority parameter to your add_action() call.

    Thread Starter buffyfan

    (@buffyfan)

    Looks like I missed this from the Woocommerce site (hidden away)

    “Note: With Storefront you do not need enqueue any of the parent theme style files with PHP from the themes functions.php file or @import these into the child themes style.css file as the main parent Storefront theme does this for you.”

    I really dislike it when people stray from conventions.

    • This reply was modified 8 years, 9 months ago by buffyfan.
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Child Theme CSS file loading twice’ is closed to new replies.