0

What is the most popular method to stop/block a plugin from loading their css styles ( located in the plugin directory) so that I can use the custom copy I made (located in my template directory).

I ask this because I have one css document ( complied using sass,scss and grunt) that a visitor of my website loads. I want to add the plugin css to that document ( and to use the sass variable functions).

Many thanks.

1

You can dequeue a style, for do that you can use wp_dequeue_style() or wp_deregister_style()

To use both of them, first u need to find the handler of the style you want.

Go to the plugin's folder you wanna remove the css and search for wp_enqueue_style or the file name and locate the handler.

wp_enqueue_style( 'my-plugin-font-awesome', plugins_url('my-plugin/font-awesome.css') );

and i need to deregister or dequeue it

add_action( 'wp_enqueue_scripts', 'my_fontawesome_deregister_styles', 100 );

function my_fontawesome_deregister_styles() {
    wp_dequeue_style( 'my-plugin-font-awesome' );
}

or

add_action( 'wp_enqueue_scripts', 'my_fontawesome_deregister_styles', 100 );

function my_fontawesome_deregister_styles() {
    wp_deregister_style( 'my-plugin-font-awesome' );
}

OBS: the priority must be higher than the plugin's wp_enqueue_scripts()

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.