• Resolved cmeers

    (@cmeers)


    I created a twentyfourteen child theme.

    https://codex.www.ads-software.com/Child_Themes instructed me to add this to the functions.php in my child theme directory:

    <?php
    add_action( 'wp_enqueue_scripts', 'enqueue_child_theme_styles', PHP_INT_MAX);
    function enqueue_child_theme_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
        wp_enqueue_style( 'child-style', get_stylesheet_uri(), array('parent-style')  );
    }

    It then appeared that the functions.php in the parent theme directory was enqueueing the child stylesheet as well. I took this out of functions.php in parent theme:

    wp_enqueue_style( 'twentyfourteen-style', get_stylesheet_uri(), array( 'genericons' ) );

    No idea about the ‘genericons’ bit, but this seems to have fixed it. Anyone have any thoughts regarding this approach?

Viewing 2 replies - 16 through 17 (of 17 total)
  • @skarr Thanks for your explanation, I was developing a child-theme and couldn’t get why it was loading twice.

    you have to enqueue your parent style dynamically in your parent theme function. then just enqueue it in your child theme function ……….don’t enqueue your child theme style again …….in my case child theme style got automatically include after the parent style.enqueue just like below it works for me:

    function theme_enqueue_styles() {
    
        $parent_style = 'porosh-style'; 
    
        wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    
    }
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );

Viewing 2 replies - 16 through 17 (of 17 total)
  • The topic ‘Child theme stylesheet loading twice’ is closed to new replies.