Welcome to the Course
Welcome! In this course you will learn how to use actions and filters in WordPress.
Target audience
The course is intended for developers looking for how to use actions and filters in WordPress to inject code and to make their code more extensible. Prior knowledge of PHP programming is recommended.
Content
The course is organized as follows.
Introduction
Actions
Filters
Resources
Frequently Asked Questions
What is the difference between actions and filters?
Actions allow us to do something when the action is triggered, whereas filters allow us to replace a value when the filter is triggered. View details.
What is the best method to find out the actions and filters available in the WordPress Core, a plugin, or a theme?
The easiest method is to read the official documentation, but sometimes it is outdated. The best way is to search the codebase for calls to the function do_action
. Each call is documented using PHPDoc comments. View details.
In the case of filters, search the codebase for calls to the function apply_filters
. View details.
I hooked a function to a filter, but the final result is not the expected value. What is happening?
The value returned by your function is being overwritten by another function hooked to the filter. During the hooking, use a big number as priority to try to place your function at the end of the queue. View details.
I am trying to unhook a function from an action, but the function is still there. What is wrong?
Make sure that you are trying to unhook the function after it is hooked to the action. Keep in mind that the priority in the remove_action
call must match the priority specified in the corresponding add_action
call. View details.
I am trying to unhook a function from a filter, but the function is still there. What is wrong?
Same answer. Make sure that you are trying to unhook the function after it is hooked to the filter, and verify that the priority in the remove_filter
call matches the priority specified in the corresponding add_filter
call. View details.
Can I hook a function to all actions?
Yes. During the hooking, specify 'all'
as action name and WordPress will execute your function each time an action is triggered. This is very uncommon. Put attention on performance if you do it. View details.
Can I hook a function to all filters?
Yes. During the hooking, specify 'all'
as filter name and WordPress will call your function each time a filter is triggered. This is very uncommon and risky. Put attention on performance if you do it. View details.
Comments