WordPress Hooks: Actions and Filters

Action and Filter Hooks:

Hooks are provided by WordPress to allow your plugin to ‘hook into’ the rest of WordPress; that is, to call functions in your plugin at specific times, and thereby set your plugin in motion. There are two kinds of hooks:

  1. Actions: Actions are the hooks that the WordPress core launches at specific points during execution, or when specific events occur. Your plugin can specify that one or more of its PHP functions are executed at these points, using the Action API.
  2. Filters: Filters are the hooks that WordPress launches to modify text of various types before adding it to the database or sending it to the browser screen. Your plugin can specify that one or more of its PHP functions is executed to modify specific types of text at these times, using the Filter API.

You can sometimes accomplish the same goal with either an action or a filter. For example, if you want your plugin to change the text of a post, you might add an action function to publish_post (so the post is modified as it is saved to the database), or a filter function to the_content (so the post is modified as it is displayed in the browser screen).

For a thorough listing of all action and filter hooks in WP see Adam Brown’s WP Hooks Database.

Source: http://codex.wordpress.org/Plugin_API


Thematic Hooks:


WordPress Hooks:


Removing Thematic Actions

Any Thematic action can be removed if desired. It’s important to note that unlike add_action, remove_action cannot be called directly by functions.php — instead, wrap the remove_action function in a wrapper function called by the ‘init’ action, like this:

// Remove default Thematic actions
function remove_thematic_actions() {

Source: http://themeshaper.com/thematic/guide/?page_id=10



Posted May 25, 2009 at 8:58 amPermalink

Hi Ian,

great post , but i’m a bit confuse on this post and the filter post , is there any good compare when you should use filter and when using action is better ?

Ian Stewart

Posted May 25, 2009 at 9:03 amPermalink

It depends on what the Theme author has done. Sometimes they’ll have made something editable with Actions, sometimes with Filters. The choice has been made for you and you shouldn’t have to decide.

%d bloggers like this: