[How To] (De-)register a Style Sheet in WordPress

How do register styles

Just like JavaScript, CSS files shouldn’t be added to WordPress directly, but by using the WordPress API.

If you want to add your own CSS file to WordPress, there are two method calls you should be aware of:


the usage is pretty simple:

wp_register_style('css-name', 'location-to-your-css-file', __FILE__), array(), 'version-number', 'screen');

this will register your CSS file and add it to the site header.

How to deregister styles

Now, if you want to get rid of a Style Sheet that is added by your theme or a plugin you use, there is also a simple way to do that (given that the methods mentioned above are used to add the Style Sheet):

wp_deregister_style (unfortunately, no description is available on the WordPress site)

You will have to know the name with which the Style Sheet is registered. For example, if you use my jQuery Colorbox plugin and choose the first theme, the Style Sheet will be registered with the name “colorbox-theme1”.

Now, in order to deregister the Style Sheet, you’ll have to add the following lines to your functions.php:

add_action( 'wp_print_styles', 'custom_deregister_styles', 100 );
function custom_deregister_styles() {
  wp_deregister_style( 'colorbox-theme1' );

wp_register_style @ WordPress Codex
wp_enqueue_style @ WordPress Codex

Leave a Reply

Your email address will not be published. Required fields are marked *