Add the following to your functions.php to display a sequential list of all actions that run on the page you’re viewing.
$debug_tags = array(); add_action( 'all', function ( $tag ) { global $debug_tags; if ( in_array( $tag, $debug_tags ) ) { return; } echo "<pre>" . $tag . "</pre>"; $debug_tags[] = $tag; } );
I find this a real life saver when tracing down bugs that are caused by/in actions/hooks.
That’s really all you need. Some blogposts are a lot shorter than others, but I guess that’s fine 🙂
Ps. I’m aware that I’m using an anonymous function which only works in PHP 5.3+ and a global what is really bad practice. This code snippet should only be used to trace down and solve a bug or do something else devy. Please remove this code afterwards, obviously don’t put this on production environments.
Vey handy. Thank you!
Woow! great save my time
Many many thanks.
It helped me finding hooks running on checkout page and i have got list
Thank you for sharing. How to display all hooks that run on your page?
Very helpful. Thank you!
It worked Thanks!
Thank you your information
very helpful
Thank you for your tutorial.
Is there a way to show the priority as well?
Thanks for this. Great tip. Only problem is it makes the page hard to read and I was getting errors saying headers already sent. This is what I did.
In wp_config.php define(‘WP_DEBUG_LOG’, true);
Then change
echo “” . $tag . “”;
to
error_log($tag);
This will put the hooks in /wp_content/debug.log
thanks man
Top merci
thank you for sharing