Site logo

Archived topic

Loading Child Theme Stylesheet as the last one

3 replies · Started by nanni75 on October 7, 2020

Viewing posts 1–4 of 4

Hello,

I have just updated to GeneratePress 3.0 and I am using a child theme (which it's using only style.css and functions.php files).

After switching to "external files" and "Flexbox" in the Customizer, the printed HTML code in the Head section of the site outputs the following:

<link rel='stylesheet' id='generate-widget-areas-css'  href='https://www.example.com/wp-content/themes/generatepress/assets/css/components/widget-areas.min.css?ver=3.0.0' media='all' />
<link rel='stylesheet' id='generate-style-css'  href='https://www.example.com/wp-content/themes/generatepress/assets/css/main.min.css?ver=3.0.0' media='all' />
<style id='generate-style-inline-css'>
#nav-below {display:none;}.resize-featured-image ... etc
</style>
<link rel='stylesheet' id='generatepress-dynamic-css'  href='//www.example.com/wp-content/uploads/generatepress/style.min.css?ver=5.5.1' media='all' />
<strong><link rel='stylesheet' id='generate-child-css'  href='https://www.example.com/wp-content/themes/generatepress_child/style.css?ver=1599233625' media='all' /></strong>
<link rel='stylesheet' id='generate-blog-css'  href='https://www.example.com/wp-content/plugins/gp-premium/blog/functions/css/style.min.css?ver=1.12.1' media='all' />
<link rel='stylesheet' id='generate-navigation-branding-css'  href='https://www.example.com/wp-content/plugins/gp-premium/menu-plus/functions/css/navigation-branding-flex.min.css?ver=1.12.1' media='all' />
<style id='generate-navigation-branding-inline-css'>
@media (max-width: 1000px){.site-header, #site-navigation ... etc
</style>

I can see that the style.css of the child theme it is not loaded as the last one.

Would it be possible to load the style.css of the child theme at the bottom as the last one in order to give it the power to override all others inline and external CSS definitions?

Thanks and and a big thumb up for your great work!

Hi there,

Absolutely - try this function:

add_action( 'wp_enqueue_scripts', function() {
    wp_dequeue_style( 'generate-child' );
    wp_enqueue_style( 'generate-child' );
}, 99 );

Let us know :)

Hi Tom,

I have just tried and it works just fine! Thank you.

To add it as the very last one of the css files, I have increased the number from 99 to 999:

add_action( 'wp_enqueue_scripts', function() {
    wp_dequeue_style( 'generate-child' );
    wp_enqueue_style( 'generate-child' );
}, 999 );

Thanks a lot for your help!

You're welcome! :)

This archived topic is closed to new replies.