Adding child style sheet *after* main style sheet

Community Forums Forums General Discussion Adding child style sheet *after* main style sheet

This topic is: resolved

Tagged: 

This topic contains 6 replies, has 3 voices, and was last updated by  armadillo 1 year, 9 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #10907

    armadillo
    Participant
    Post count: 3

    I’m using Genesis 1.9.1.

    I have a slightly customized theme. I add css to a child_styles.css file to override the standard styles.css file in the base child theme files.

    I add my new style sheet using:


    add_action('get_header', 'child_load_styles');
    function child_load_styles() {
    wp_enqueue_style('child_style_css', CHILD_URL . 'child_styles.css');
    }

    However, this puts my child_styles sheet above the styles sheet in the rendered HTML.

    I see a note about 1.9.1 that suggests the update is related to this – it was working before the update. But, I’m not sure what I have to change to get my child sheet loaded after the standard sheet.

    Any advice?

    #11394

    wpsmith
    Moderator
    Post count: 178

    Why don’t you just change the styles in style.css??


    Travis Smith | Recommended StudioPress Developer & Contributor
    WP Smith | @wp_smith | GitHub

    Due to the forums, please paste code using Pastebin, JS Fiddle (for JavaScript) or GitHub.
    How to use Firebug for Designers by SixRevisions

    #11782

    armadillo
    Participant
    Post count: 3

    I’m trying to keep my changes separate so I can use any updated child themes. My theme is only lightly customized.

    #11788

    Bill Murray
    Participant
    Post count: 575

    Try adding your action to wp_enqueue_scripts.


    Web: https://wpperform.com or Twitter: @wpperform

    We do managed WordPress hosting.

    #12544

    wpsmith
    Moderator
    Post count: 178

    Bill’s right, but you probably want to add a priority to guarantee it comes after.


    add_action( 'wp_enqueue_scripts', 'child_load_styles', 99 );
    function child_load_styles() {
    wp_enqueue_style('child_style_css', CHILD_URL . 'child_styles.css');
    }


    Travis Smith | Recommended StudioPress Developer & Contributor
    WP Smith | @wp_smith | GitHub

    Due to the forums, please paste code using Pastebin, JS Fiddle (for JavaScript) or GitHub.
    How to use Firebug for Designers by SixRevisions

    #12558

    Bill Murray
    Participant
    Post count: 575

    @Travis – Per this, isn’t the default priority on the main child theme stylesheet = 5? Adding the action without specifying a priority uses the default of 10, and since 10 is later than 5, is specifying a priority really helpful? If so, how so?


    Web: https://wpperform.com or Twitter: @wpperform

    We do managed WordPress hosting.

    #13891

    armadillo
    Participant
    Post count: 3

    Adding the action to wp_enqueue_scripts worked great. Thanks!

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.