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

Is there a way to check if a custom hook gets called upon? I would like to display a placeholder if no output will be passed to it.

share|improve this question
up vote 4 down vote accepted

I believe you are looking for has_action, which should ...

Check if any action has been registered for a hook.

if (has_action('custom_action')) {
  // stuff
} else {
  // different stuff
share|improve this answer
Hm, okay, so this is what the question really was about... ;) – tfrommen Feb 19 '14 at 19:06

Do you know did_action?

If I understood you correctly, you are looking for something like the following:

if (0 === did_action('custom_action')) {
    // placeholder, or whatever
share|improve this answer
Although did_action() is very useful too it works a little differently than what I was looking for in the end. If I'm correct did_action() counts the amount of time a specific do_action($) has been executed on different locations right? – user17235 Feb 19 '14 at 19:38
Yes, that's right. And that's how I understood your question. Determine if a specific action has been called (until now) and react on that data. has_action() returns true if there is at least one action registered - but it doesn't care if it's already been called or not. – tfrommen Feb 19 '14 at 19:49

Your Answer


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