Is there an effective method to find a place where wordpress's hook is declared and when it's activated?

For example:
I know that get_header hook is declared inside wp-includes\general-template.php -- function get_header(...). When this function is called, the hook is activated.

In this case that was easy but the rest hooks are harder to localize e.g the hooks in admin dashboard.

2 Answers 2


Here in this page its the list of all action and filter hooks, just click on one and it will tell you in which file you can find it, a partial view of where is declared, and below are the related hooks.

you can see a list of hooks and the functions attached to it using:

$hook_name = 'wp_head';
global $wp_filter;
var_dump( $wp_filter[$hook_name] );

i am using 'wp_head' as an example, but you can use a hook related to the event (you said location) and start digging, for known events you can just do a google search, the common ones will show, and you can use them as $hook_name

  • This method works when I know the hook's name. What if I want to run my function in location 'x' but I don't know which hook is called?
    – rflw
    Commented Feb 11, 2017 at 7:43
  • you can see a list using this global $wp_filter;
    – David Lee
    Commented Feb 11, 2017 at 20:32

You can perform a search on https://developer.wordpress.org/reference for functions, hooks, etc. that you need. They will give you results to Codex pages.

enter image description here

Once you perform a search, each result will display the source file. This information can also be found on individual Codex pages for the functions. It will be towards the bottom under "Source" section.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.