
To disable a specific plugin’s stylesheet in WordPress, you can follow these steps:
WordPress is very flexible. You can do tons of things and customization with it. When activated, some plugins automatically ads their css stylesheet to your WordPress blog. This is great in most cases, but it is a lot cleaner to have all your css styles in one stylesheet. How can you remove a CSS file that was registered with wp_enqueue_style
?
- Access the source code of your WordPress website: You can access the source code of your WordPress website through the file manager of your hosting account or by using an FTP client.
- Find the plugin’s stylesheet file: The plugin’s stylesheet file is usually located in the
wp-content/plugins/<plugin-name>/css/
directory, where<plugin-name>
is the name of the plugin you want to disable the stylesheet for. - Dequeue the stylesheet: To dequeue the stylesheet, you need to add a few lines of code to your WordPress theme’s functions.php file. The code to dequeue the stylesheet should look like this:
function crunchify_remove_plugin_stylesheet() { wp_dequeue_style( '<style-handle>' ); wp_deregister_style( '<style-handle>' ); } add_action( 'wp_enqueue_scripts', 'crunchify_remove_plugin_stylesheet', 100 );
Note: Replace <style-handle>
with the handle of the plugin’s stylesheet, which can usually be found in the plugin’s source code or by using the browser inspector to inspect the page source.
- Save and upload the changes: After making the changes, save the
functions.php
file and upload it back to your server.
These steps should disable the specific plugin’s stylesheet in WordPress. However, keep in mind that disabling the stylesheet can cause compatibility issues and break the layout of the pages that use the plugin.
Real example to disable specific plugin’s stylesheet:
Step1:
Open plugin file and look for code starting with wp_enqueue_style
( $handle, $src, $deps, $ver, $media );. Look for handle name.
Sample: If you are using Redirection Plugin, look for below line of code and get handle name redirection
.
wp_enqueue_style( 'redirection', plugin_dir_url( __FILE__ ).'admin.css', $this->version() );
Step2:
Open functions.php
file and enter below code:
add_action( 'wp_print_styles', 'deregister_my_styles', 100 ); function deregister_my_styles() { wp_deregister_style( 'redirection' ); }
Let me know if you have any questions about above solution.