Display all hooks that run on your page

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 ) ) {
	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.

Related Posts

Powered By Related Posts for WordPress
Click Here to Learn More About Related Posts for WordPress

13 thoughts on “Display all hooks that run on your page

  1. Vey handy. Thank you!

  2. Woow! great save my time

  3. Many many thanks.

    It helped me finding hooks running on checkout page and i have got list

  4. Thank you for sharing. How to display all hooks that run on your page?

  5. Very helpful. Thank you!

  6. It worked Thanks!

  7. Thank you your information

  8. very helpful
    Thank you for your tutorial.

  9. Is there a way to show the priority as well?

  10. Ira Rabinowitz

    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 . “”;



    This will put the hooks in /wp_content/debug.log

  11. thanks man

  12. John Connors

    Top merci

  13. thank you for sharing

Leave a Reply

Your email address will not be published. Required fields are marked *