I have an specific page on my website where I can’t have any stylesheets being enqueued, so I need to unenqueue all stylessheets loaded there. Problem is I don’t know their IDs, because they can come from either several different themes or other plugins.
What I’ve tried to do is remove the wp_enqueue_styles action, but without luck.
Here’s what I’ve tried:
add_action( 'init', 'remove_enqueue_action', 99);
function remove_enqueue_action() {
remove_action( 'wp_enqueue_styles','' );
}
Any help is appreciated.
Check the
$wp_styles
global to get the stylesheet IDs.Look for the
handle
key. Or…That should give you what you need to dequeue them.
it can be done where you are actually enqueue your scripts
like this
Working on that global vars cycling gives you a full array of all the styles loaded at the time you process the same one, so you can dequeue them all just specifying each handle.