Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

2 Answers 2

up vote 5 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... ;) –  t f Feb 19 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? –  Jesper Purola Feb 19 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. –  t f Feb 19 at 19: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.