Showing WordPress Hooks on Pages

Last Updated on April 2, 2024 EDT by Gina

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.Copy

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;
	}
}

This code is from https://sarathlal.com/display-all-hook-sequentialy-that-run-on-page-wordpress/

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.

Show Hooks – WordPress plugin | WordPress.org English (Canada)
Show the origin of a action or filter hook sequentially which helps a developer to debug quickly.
en-ca.wordpress.org

Method 3 – ?

0 Shares:

Comments are closed.


You May Also Like