Showing WordPress Hooks on Pages

Tags
development
Created Date
November 30, 2021

Intro

From time to time you might forget what hooks to use in WordPress. The following article will explain how to show the hooks on your site's frontend so you can locate them easily.

Method 1 - Echo in HTML

This is easy if you add the following code to your functions.php or via the "Code Snippets" plugin. This might break your site, but you can always view source on the page and see the hooks.

add_action( 'all', 'th_show_all_hooks' );
	
function th_show_all_hooks( $tag ) {
	if(!(is_admin())){ // Display Hooks in front end pages only
		$debug_tags = array();
		global $debug_tags;
		if ( in_array( $tag, $debug_tags ) ) {
			return;
		}
		echo "<pre>" . $tag . "</pre>";
		$debug_tags[] = $tag;
	}
}

Method 2 - Show Hooks Plugin

This plugins is pretty great, however it's hard to use. Sometimes there's too many hooks and you can't find the one you're looking for.

Method 3 - ?