WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

There's a function attached to a set of actions, like this:

add_action('some_tag', 'the_function');

function the_function($maybe_some_vars){
  // ...

Is it possible to find out the action name ("some_tag") within the_function?

The reason I'm asking, is that I'm attaching the function to multiple actions (some of them custom, some belong to WP like the_content). The code that executes within the function depends on knowing the name of the action.

I did manage to get it using debug_backtrace(), but I'm pretty sure that's not a very reliable way.

share|improve this question
up vote 3 down vote accepted

Simple: current_filter(); (link to plugin.php) or global $wp_current_filter;.

share|improve this answer
Thanks, I knew about it and didn't think about using it! :) – onetrickpony May 6 '12 at 18:58
n/p. We all got moments where we simply forget about the obvious stuff. :) – kaiser May 6 '12 at 18:59

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.