How can I dequeue a Plugin Stylesheet?

I am currently using a Plugin, which has created a Stylesheet within the following directory: /wp-content/uploads/plugin-name/css.

I would like to remove this Plugin’s Stylesheet, since it is being called after my Custom Stylesheet, where the Plugin is performing unwanted overrides of the Custom Stylesheet.

Instead, I want to remove the Plugin’s Stylesheet; copying only required styles into the Custom Stylesheet.

I tried placing the following into the functions.php file, within the Child Theme:

<?php
function dequeue_dequeue_plugin_style(){
    wp_dequeue_style( 'plugin-css' ); //Name of Style ID.
}
add_action( 'wp_enqueue_scripts', 'dequeue_dequeue_plugin_style', 999 );
?> 

Unfortunately, this did not work. Is anyone able to see if I have gone wrong with my Code or whether Plugin Styles have priority over all files within a Child Theme etc.

2 Answers
2

My error. All I had to do was knock off the -css and it worked.

Working code:

<?php
function dequeue_dequeue_plugin_style(){
    wp_dequeue_style( 'plugin' ); //Name of Style ID.
}
add_action( 'wp_enqueue_scripts', 'dequeue_dequeue_plugin_style', 999 );
?> 

Leave a Comment