• I’m trying to deregister CSS files from my WordPress site, but it doesn’t work. I’m using Avada template, I’ve added this code to “functions.php”:

    function remove_unwanted_css(){
        wp_deregister_style('dashicons-css');
        wp_dequeue_style('thickbox-css');
        wp_dequeue_style('contact-form-7-css');
    }
    add_filter('wp_footer', 'remove_unwanted_css');

    As you can see, I tried both “deregister” and “dequeue”, but the CSS files keeps loading. I cleared every possible cache.

    This is from my source file when I load the website (www.bmpaints.co.il)

    <link rel='stylesheet' id='dashicons-css'  href='http://www.bmpaints.co.il/wp-includes/css/dashicons.min.css?ver=4.5.3' type='text/css' media='all' />
    <link rel='stylesheet' id='thickbox-css'  href='http://www.bmpaints.co.il/wp-includes/js/thickbox/thickbox.css?ver=4.5.3' type='text/css' media='all' />
    <link rel='stylesheet' id='contact-form-7-css'  href='http://www.bmpaints.co.il/wp-content/plugins/contact-form-7/includes/css/styles.css?ver=4.4.2' type='text/css' media='all' />

    What am I missing..?

    Thanks

Viewing 1 replies (of 1 total)
  • Geoffrey Shilling

    (@geoffreyshilling)

    Volunteer Moderator

    What about something like this:

    function remove_unwanted_css(){
        wp_deregister_style('dashicons-css');
        wp_dequeue_style('dashicons-css');
        wp_deregister_style('thickbox-css');
        wp_dequeue_style('thickbox-css');
        wp_deregister_style('contact-form-7-css');
        wp_dequeue_style('contact-form-7-css');
    }
    add_action( 'wp_enqueue_scripts', 'remove_unwanted_css', 20 );

    Does that work?

Viewing 1 replies (of 1 total)

The topic ‘Deregister CSS file’ is closed to new replies.