Removing specific style from wp_head

Note: the file name is functions.php, not function.php (but that’s probably just a typo in the question).

To remove a script or style, you must remove it after it was added. If you try to remove it before it was added, or even print $GLOBALS['wp_scripts']->registered, nothing will happen, since it was not added yet.

So a way to remove them is to execute the _remove_style function as late as possible.

Also, you need to make sure you are using the correct handle that was used to enqueue the CSS file in the first place. In this case, the correct handle is: yasrcss (credit to @thedeadmedic).

Combining all these, you may try the following CODE:

add_action( 'wp_enqueue_scripts', '_remove_style', PHP_INT_MAX );
function _remove_style() {
    wp_dequeue_style( 'yasrcss' );
}

Leave a Comment