Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deregister style.css in WordPress

Does anyone know if it's possible to deregister the default stylesheet of a theme, style.css, in WordPress? I've tried going wp_deregister_style('style') and wp_deregister_style('style.css'), but neither seems to work.

I'm hoping to do this so I can optimise my site my combining my various stylesheets into one and minifying it with an Ant script.

like image 225
And Finally Avatar asked May 31 '12 13:05

And Finally


People also ask

How do I deregister a style in WordPress?

WordPress includes 2 functions which you can use in your child themes functions. php file to deregister and dequeue style sheets for themes and plugins. Deregister a CSS file that was registered with wp_register_style(). Dequeue a CSS file that was enqueued with wp_enqueue_style().

How do I remove unwanted CSS from my WordPress site?

On the post edit screen, you'll find the Asset CleanUp box just below the post editor. The plugin will automatically fetch and list all the files and assets loaded when a visitor views this page on your website. You can then simply unload the unused CSS or JavaScript files that you don't need on that page.

How do I override a CSS style in WordPress?

Easiest: use the Customizer Clicking on the Customize menu link will take you to the Customizer panel. The CSS editor can be found under the Additional CSS panel. The CSS editor is essentially a mini code editor for you to add your own custom CSS: The CSS editor in the WordPress Customizer.


1 Answers

According to Wordpress behavior, which requires to pass a handle when registering and de-registering a stylesheet, and as the default stylesheet "style.css" is registered with the handle "screen", we should use this code :

wp_dequeue_style('screen');
wp_deregister_style('screen');
like image 148
Nicolas Lagarde Avatar answered Sep 23 '22 15:09

Nicolas Lagarde



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!