• kemmieg

    (@kemmieg)


    I’m using the TwentyTwenty theme as the parent theme for a site I’m working on. I’ve used

    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
     
        $parent_style = 'parent-style'; 
     
        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')
        );
    }

    from the WP handbook for child themes but it’s loading the stylesheets wrong.
    Here is what I see when I view the source file

    <link rel='stylesheet' id='child-style-css'  href='https://hifu.wpengine.com/wp-content/themes/hifu/style.css?ver=1.0.0' media='all' />
    <link rel='stylesheet' id='twentytwenty-style-css'  href='https://hifu.wpengine.com/wp-content/themes/hifu/style.css?ver=1.0.0' media='all' />

    I’m not sure what is going on I’ve never run into this before.

    This is in my child theme css

    /*
    Theme Name: HIFU Theme
    Theme URI: https://webdonewell.com
    Author: Webdonewell
    Description: HIFU Training Theme
    Template: twentytwenty
    Version: 1.0.0
    */

    I really need to get this resolved. I’m sure I’m just missing something simple.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    You do not have to enqueue the child theme’s style sheet. That happens automatically.

    All you need is

    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    Thread Starter kemmieg

    (@kemmieg)

    Unfortunately that did not work. I’m still getting the parent theme after the child theme

    Thread Starter kemmieg

    (@kemmieg)

    Sorry it is loading correctly but it looks like the Twenty Twenty theme has a bunch of inline styles which are loading after the child theme css. Also, my child theme css still isn’t overriding the parent theme.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    I recommend asking at https://www.ads-software.com/support/theme/twentytwenty#new-post so the theme’s developers and support community can help you with this.

    Thread Starter kemmieg

    (@kemmieg)

    Awesome. Thanks for your help

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Twenty Twenty Child theme Loading parent theme last’ is closed to new replies.