Display all WordPress Hooks on a page
When debugging and troubleshooting of WordPress websites, display all action and filter WordPress hooks used in a page using a simple PHP snippet. You can find the hook that may cause a problem on your site, alternatively, you can use any hook to extend the ability of the WordPress website.
It can help you to resolve the following queries.
* WordPress content hooks
* WordPress hook order
* WordPress hooks list
* Action and filter hooks in WordPress
For example, you are looking for “after save post hook WordPress”. You can list all the hooks using this code. Then you can find in the list of hooks, which hook is triggered right after the save_post hook.
Add this code to your theme or plugin file. The suggested file for themes is functions.php and the main file of any plugin for plugins.
$debug_tags = array();
add_action( 'all', function ( $tag ) {
global $debug_tags;
if ( in_array( $tag, (array) $debug_tags ) ) {
return;
}
echo "<pre>" . $tag . "</pre>";
$debug_tags[] = $tag;
} );
Action and filter hooks in WordPress
The difference between action and filter hook is:
Action Hooks are a very useful tool in WordPress and they are used to perform functions (actions) in specific locations of a theme or plug-in.
For Example, ‘woocommerce_before_main_content’ hooks can be used to add notices, and messages on every shop page.
While filter hooks are used to provide access to data used by any plugin or theme.
For example, WooCommerce is getting the price of a product to show it and calculate totals in the cart. You can use the ‘woocommerce_product_get_price’ filter hook to apply discounts on prices or change the price of a product dynamically.
“the_content” hook can be used to replace a specific word/sentence/whole content of a post.

Raja Aman Ullah is a highly skilled WordPress and WooCommerce plugin developer working as a lead plugin developer. He developed numerous famous extensions including b2b, request a quote, ultimate membership, custom fields, and many others for WooCommerce that are trending on Extension Store. His products on WooCommerce have more than 100,000 active subscriptions and happy clients.
Hire me
Pingback: How to differentiate between Action And Filter Hooks