Check and dequeue if multiple stylesheets exists using wp_style_is?

I have not tested this, but I imagine it is because you are passing an array to the $handle variable in your wp_style_is() function and not a string.

Maybe try looping through the array so you pass it a single string to check against each time.

Something Like this…

add_action('wp_enqueue_scripts', 'dequeue_by_handles', 999);

function dequeue_by_handles() {

    $handles = array(
        'fontawesome',
        'font-awesome',
        'font-awesome-style'
        );

    foreach ($handles as $handle) {

        if ( wp_style_is( $handle, $list="enqueued" ) ) {
            wp_dequeue_style( $handle );
        }
    }
}

Leave a Comment