Archived topic
How to load blog stylesheet on every page?
4 replies · Started by James on July 30, 2021
I am trying to load comments.min.css and style.min.css (the one from the GP Premium plugin) on all pages. The reason for this is because I am using Autoptimize to combine css and want to have a common combined file for all pages.
I am already loading the comments.min.css with the following.
wp_enqueue_style( 'generate-comments', get_template_directory_uri() . "/assets/css/components/comments.min.css", array(), GENERATE_VERSION, 'all' );
What do I need to do to load /wp-content/plugins/gp-premium/blog/functions/css/style.min.css on every page?
I have tried this.
wp_enqueue_style( 'generate-sections-styles', '/wp-content/plugins/gp-premium/blog/functions/css/style.min.css' );
It works, but it uses the same query string version number as the style.min.css located in /wp-includes/css/dist/block-library/style.min.css
Normally it has it's own query string when loaded on the blog archive pages.
After more testing I realized that none of the css in /wp-content/plugins/gp-premium/blog/functions/css/style.min.css is actually used so I'm trying to dequeue it.
wp_dequeue_style( 'generate-sections-styles' ); inside of my function that deques other styles is not working for some reason.
Hi there,
If you want to dequeue the blog stylesheet, you can add the following:
add_action( 'wp_enqueue_scripts', function() {
wp_dequeue_style( 'generate-blog' );
}, 100 );
Let me know if you need more info :)
Hi Tom,
That is strange, I didn't get an email notification of your reply here as I usually do. Anyway, I ended up figuring it out after I realized the handle name corresponds to the link rel id on the front end html.
Initially I searched all the files in the GP premium plugin for the text 'style.min.css', the only result is in generate-sections.php line 67, as below.
wp_enqueue_style( 'generate-sections-styles', plugin_dir_url( __FILE__ ) . 'css/style.min.css' );
So that's why I thought the handle was generate-sections-styles.
Anyway, thanks for the reply.
No problem! :)