WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Lots of hooks:

add_action('thesis_hook_after_comment', 'pj_time');
add_action('thesis_hook_after_comments', 'pj_time');
add_action('thesis_hook_after_comment_box', 'pj_time');
add_action('thesis_hook_after_comment_meta', 'pj_time');
add_action('thesis_hook_after_content', 'pj_time');
add_action('thesis_hook_after_content_area', 'pj_time');
add_action('thesis_hook_after_content_box', 'pj_time');
add_action('thesis_hook_after_footer', 'pj_time');
add_action('thesis_hook_after_header', 'pj_time');
add_action('thesis_hook_after_headline', 'pj_time');
// etc.

How can function pj_time() know which hook called it? Is there a global variable or something that tells me which hook we're on? So pj_time() could output something like: "The hook (name of hook here) rocks."

I don't know the order the hooks are called either, they're just in alphabetical order here. Otherwise I could use a counter to figure how many hooks we've done so far and determine the name of the hook that way.

So I want to know if it's possible to get the name of the hook. Thanks.

share|improve this question
Here's the source of what I was attempting to do pjbrunet.com/… – PJ Brunet Oct 28 '13 at 17:47
function pj_time () {
    echo current_filter();

Easier than I thought ;-)


share|improve this answer
+1 Another cool thing is that you can use that to remove functions and methods as well: remove_function( current_filter(), __FUNCTION__ ); and remove_function( current_filter(), array( $this, __FUNCTION__ ) );. Only problem is that you'd still have to extract the priority if it's not 10. – kaiser Oct 27 '13 at 3:58
Sure. We use it in our WCM Language switcher plugin. – kaiser Oct 28 '13 at 17:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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