Understanding Wordpress Actions and Filters

10th Feb 2014

Wordpress action and filter hooks are what makes Wordpress incredibly extendable. These hooks are very easy to use if someone else has already wrote them, and you just had to hook something in. Understanding how they work is another matter entirely.

In this post, I’m going to walk you through my personal understanding of Wordpress action and filer hooks after a few hours of experiments.

The Difference Between Actions and Filters

The main difference between actions and filters is the purpose they are used for and how they are declared and used. Here’s a quick summary.

  • Actions When something has to be added declared with add_action(). used with do_action().
  • Filters When something has to be changed declared with apply_filters(). used with add_filters().

Not sure you get what I mean? Lets dive into some examples of creating and using actions and filters.

Creating Wordpress Actions

You can create a wordpress action with the following code.

If you enjoyed this article, please tell a friend about it! Share it on Twitter. If you spot a typo, I’d appreciate if you can correct it on GitHub. Thank you!

Hold on while i sign you up…

🤗
Woohoo! You’re in!
Now, hold on while I redirect you.