> For the complete documentation index, see [llms.txt](https://githubichsan.gitbook.io/journal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://githubichsan.gitbook.io/journal/wordpress-development/hooks.md). Agents can also search and read this documentation through its [MCP server](https://githubichsan.gitbook.io/journal/~gitbook/mcp).

# Hooks

Hooks are a way for one piece of code to interact/modify another piece of code at specific, pre-defined spots. They make up the foundation for how plugins and themes interact with WordPress Core.

There are two types of hooks: [Actions](https://developer.wordpress.org/plugins/hooks/actions/) and [Filters](https://developer.wordpress.org/plugins/hooks/filters/). To use either, you need to write a custom function known as a `Callback`, and then register it with a WordPress hook for a specific action or filter.

### [Actions vs. Filters](https://developer.wordpress.org/plugins/hooks/#actions-vs-filters) <a href="#actions-vs-filters" id="actions-vs-filters"></a>

The main difference between an action and a filter can be summed up like this:

* an action takes the info it receives, does something with it, and returns nothing. In other words: it *acts* on something and then exits, returning nothing back to the calling hook.
* a filter takes the info it receives, modifies it somehow, and returns it. In other words: it *filters* something and passes it back to the hook for further use.

Said another way:

* an action interrupts the code flow to do something, and then returns back to the normal flow without modifying anything;
* a filter is used to modify something in a specific way so that the modification is then used by code later on.

<br>
