Hooks (actions & filters)

WordPress hooks allow you to tap into WordPress on specific points to change how WordPress behaves without editing any core files.

There are two types of hooks within WordPress: actions and filters. Actions allow you to add or change WordPress functionality, while filters allow you to alter content as it is loaded and displayed to the website user.

You can sometimes accomplish the same goal with either an action or a filter.


An action is a function in WordPress code that is run at certain points throughout the WordPress core. … These are a part of what makes WordPress so extensible and most plugins depend on actions for their operation.

To create a new action, click the Add button and select the Action item.
From the new feature dialog, pick an existing action or create a new one.
If the hook name has dynamic parts, the corresponding fields are displayed and must be filled.

If the action name doesn’t exist, it considers that’s a new action and allow you to define the argument list. Later, it can be called from another action.
It’s a powerful way to keep your feature easy to maintain.


In WordPress, filters are functions that can be hooked to an event (called hooks). During the execution when the event is triggered the filter is applied to the data output generated by the event hook.

Filters must always return a value !

Autoload & priority

By default, actions and filters hooks are added automatically during the loading of the feature.

You can disable autoload and register your actions or filters dynamically in other actions. See “How to make it modular?

The priority determines when the callback function will be executed in relation to the other callback functions associated with a given hook.

A function with a priority of 11 will run after a function with a priority of 10; and a function with a priority of 9 will run before a function with a priority of 10. Any positive integer is an acceptable value, and the default value is 10.

If two callback functions are registered for the same hook with the same priority, then will be run in the order that they were registered to the hook.

Toggle hook autoload and set priority