What can add_action hook too? (2 posts)

  1. dcole07
    Posted 7 years ago #

    When using add_action, you have to insert a hook name. Can this name be any PHP function that's defined and called or what are the guidelines?

    The documentation says: hook_name is the name of an action hook provided by WordPress, that tells what event your function should be associated with.

    If I can't use any php function name I created, how can I add the name to think action hook name list or what not?

  2. They come in pairs. The add_action function takes a hook name and a function name to call. But it's actually run when there is a do_action call, which specifies the hook name.

    So, this code:


    would cause the do_something function to run.

    So look for the corresponding do_action to figure out where your hook is called from.

    Filters work the same way, with add_filter and apply_filter.

Topic Closed

This topic has been closed to new replies.

About this Topic