Hooks
Introduction #
Hooks are a way for one piece of code to interact with and modify another piece of code. They make up the foundation for how plugins and themes interact with WordPress Core, but they’re also used extensively by Core itself.
There are two types of hooks: Actions and Filters. To use either, you need to write a custom function known as a callback, and then register it with WordPress for a specific action or filter.
Filters give you the ability to change the value of a piece of data during the execution of WordPress. Callback functions for filters will be passed through a variable, modified, and then returned. They are meant to work in an isolated manner, and should never affect global variables or anything else outside of the function.
Actions, in contrast, allow you to add to or change how WordPress operates. Your callback function will run at a specific point in in the execution of WordPress, and can perform some kind of task, like echoing output to the user or inserting something into the database.
WordPress provides many hooks that you can use, but you can also create your own so that other developers can extend and modify your plugin or theme.
External Resources #
- Filter Reference
- Action Reference
- Adam Brown’s database of hooks
- Actions and Filters are Not the Same Thing


