Check if do_action(‘custom_action’) is hooked into?

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.

Related posts

2 comments

  1. 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
    }
    
  2. 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
    }
    

Comments are closed.