Action Hook Functions – remove_all_actions()
remove_all_actions() function removes all actions added to a specified hook with just a single line of code instead of multiple class to the
<?php remove_all_actions( $tag, $priority ); ?>
$tag— The name of the action hook on which you want to remove all actions on.
$priority— The priority of the actions to remove. However, this parameter is optional and defaults to false if not given. Setting this parameter will result in only actions with this specific priority being removed.
Examples on how to remove actions using remove_all_actions()
This example shows how you can remove all actions, regardless of
priority, from the
wp_head action hook.
<?php remove_all_actions( 'wp_head' ); ?>
However, if you want to remove only actions with a specific priority, you should specify a value for the
$priority parameter. Say you want to remove all actions with a priority of 1 for the
wp_head hook, you use the following code.
<?php remove_all_actions( 'wp_head', 1 ); ?>
Here is how a website looks like:
before running remove_all_actions( ‘wp_head’ );
after running remove_all_actions( ‘wp_head’ );
Not good, right? Be careful when using this function, that is if there arises a very special case in which you have to absolutely use it. Oftentimes, other plugins and themes add actions that you might not be aware of. Using
remove_all_actions() ends up breaking the site functionality. As a rule of thump, always be as specific as possible with your code by using