admin管理员组

文章数量:1125591

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?

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?

Share Improve this question asked Feb 22, 2024 at 5:13 A. MullerA. Muller 518 bronze badges 1
  • 1 What 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 Commented Feb 22, 2024 at 7:27
Add a comment  | 

2 Answers 2

Reset to default 0

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' );

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/

本文标签: themesHow to cancel stylemincss file