Cyber Week Sale! Get $20 off GP Premium, $40 off our new Lifetime license, and 45% off license renewals/extensions! Learn more

[Resolved] Child Theme – loading style.css *after* other style sheets?

Home Forums Support Child Theme – loading style.css *after* other style sheets?

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
  • #306832

    I am using the child theme you provide on your site and save my CSS to its style.css.

    Apparently the child theme’s style.css is loaded before the style sheets from the GP Premium add-ons, so styles with the same specifity are being overwritten.

    Is there any way to load the child theme’s CSS after the other style sheets?

    GeneratePress 1.3.46
    GP Premium 1.2.96
    Customer Support

    Hi Peter,

    Just making sure you are not enqueue the parent style sheet? The theme loads it automatically for you:

    Let me know if this helps.

    Lead Developer
    Lead Developer

    Some stylesheets might be added after the child stylesheet, but you can counter that by making your CSS more specific.

    For example, add body in front of your custom CSS:

    body .site-header {
        margin-top: 10px;

    @Leo Thanx for you reply, but the functions.php of the child theme is (almost) empty. The only reference to the parent theme is in the Template-comment of the Child-Theme’s style.css.

    Thanx for the hint, but that’s precisely what I wanted to avoid ๐Ÿ˜‰

    Lead Developer
    Lead Developer

    Any reason why?

    You could try this:

    add_action( 'wp_enqueue_scripts', 'tu_child_scipts', 999 );
    function tu_child_scipts() {
        wp_dequeue_style( 'generate-child' );
        wp_enqueue_style( 'generate-child', get_stylesheet_uri(), array( 'generate-style' ), filemtime( get_stylesheet_directory() . '/style.css' ), 'all' );

    Thanx a lot, the add_action did the trick. The snippet dequeues the style sheet from the child theme and then loads all GP-stylesheets in an array sorting them by time stamp?

    >> [specificity] thatโ€™s precisely what I wanted to avoid
    > Any reason why?

    Starting every selector with something like body just to increase specificity somehow feels, uhm, wronggg. Changing the load order seems cleaner.

    Lead Developer
    Lead Developer

    It simply removes the stylesheet and then re-adds it. The trick is the hook priority being set to 999 which is later than anything else. That loads it after all of the other hooks.

    I see your point ๐Ÿ™‚


    i know its an old thread but had the same problem in 2020. need to dequeue and requeue my own style.css because it was loaded before sticky.min and GP style. therefore overwriting some css rules was complicated. custom style.css from child theme should always loaded at last.

    Lead Developer
    Lead Developer

    This is a tough one to fix on our end now, unfortunately. If we were to force it to load after everything at this point, there’s a high probability people might run into issues with their CSS after updating.



Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.