I'm writing style codes for a WordPress theme. But the theme reads the style codes from the style.min.css file. I just want it to read from the style.css file. How can I disable it from reading from this compressed css file?
-
1What style.min.css file? Is it coming from WordPress or a theme? If it's from WordPress you're probably referring to the block styles. These are required for content created with the block editor to appear correctly on the front end. If you stop it from loading you're just going to need to rewrite it all anyway.Jacob Peattie– Jacob Peattie2024-02-22 07:27:56 +00:00Commented Feb 22, 2024 at 7:27
2 Answers
you can be used enqueueing your own CSS file and deregister the default stylesheet using Wp default hook
Replace default-theme-style with to register name mentioned in the minified CSS style link.
Add code in functions.php file
Deregister for style.min.css
function deregister_default_stylesheet() {
// Deregister the default stylesheet
wp_deregister_style( 'default-theme-style' );
}
add_action( 'wp_enqueue_scripts', 'deregister_default_stylesheet', 20 );
// Enqueue your own stylesheet `style.css`
function theme_enqueue_styles() {
// Enqueue your own stylesheet
wp_enqueue_style( 'my-css-style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
-
The compressed css file is inside a plugin. Does this require making any further changes?A. Muller– A. Muller2024-02-22 13:18:06 +00:00Commented Feb 22, 2024 at 13:18
You can enqueue your stylesheet this is how: https://developer.wordpress.org/reference/functions/wp_enqueue_style/
You can dequeue the existing stylesheet this is how: https://developer.wordpress.org/reference/functions/wp_dequeue_style/
-
Not working. Can you elaborate a little more?A. Muller– A. Muller2024-02-22 05:40:55 +00:00Commented Feb 22, 2024 at 5:40
-
Did you dequeue the existing stylesheet?Syed Muhammad Usman– Syed Muhammad Usman2024-02-22 06:53:54 +00:00Commented Feb 22, 2024 at 6:53