Understanding Wordpress Actions and Filters
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.
When something has to be added
add_action(). used with
When something has to be changed
apply_filters(). used with
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.Thanks for reading. Did this article help you out? If it did, I hope you consider sharing it. You might help someone else out. Thanks so much!