In WordPress, how to tell what hook is calling the current function?

Putting this down both for posterity for myself, as well as to help anyone else who may be wrestling with the same thing.

When developing plugins/themes for WordPress, it’s often vital to figure out what hook is calling the current function, because hooks don’t take the passing of specific additional parameters.

So how do you do that?  Absurdly simple actually…

global $wp_current_filter;

Of course, $wp_current_filter[0] will actually hold the string of the name of the current hook, such as the_content, init, etc.



Leave a Reply

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