4

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
  • Please specify which plugin so we can have a look how it enqueues the css file.
    – sandrodz
    Feb 13 '18 at 20:20
  • Thanks for your comment. Just figured that if I take away the -css, the code works.
    – Craig
    Feb 13 '18 at 20:21
3

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 );
?> 
1

You can easily do it. For style, you have to follow the following codes-

function scp_assets_dequeue() {
    wp_dequeue_style( 'wpcp-slick' ); // style id
} 
add_action( 'wp_enqueue_scripts', 'scp_assets_dequeue', 9999);

Similarly for script, you have to try the following code-

function scp_assets_dequeue() {
    wp_dequeue_script( 'wpcp-slick' ); // script id
} 
add_action( 'wp_enqueue_scripts', 'scp_assets_dequeue', 9999);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.