Do you want to be a wordpress developer?
And also want to know the main building blocks of wordpress?
Well, then consider yourself very lucky today as you have landed on the right resource on wordpress hooks.
WHAT ARE WORDPRESS HOOKS?
Hooks enable the functionality to run a certain task at a particular time defined by your function.
Still not clear?
It gives you the power to run some codes at a particular time by hooking into the wordpress workflow so that you can get your desired workflow without modifying the wordpress core files.
Still, it doesn’t make more sense to you? Don’t worry thing becomes more clear down the line, stay tuned.
There are two kinds of hooks:
- WordPress Action Hooks
- WordPress Filter Hooks
WHAT ARE WORDPRESS ACTIONS?
Actions enable you to execute a function at specific points. It triggers when some event takes place like the publishing of post, loading of the footer.
Steps of registering an action to the action hook.
- Create a PHP function that you want to run when the event occurs.
- Add this function to the event using the add_action function.
add_action? What is it?
Woohoo! It’s a function in wordpress that hooks your callback function(action you want to perform) to the event you defined in add_action.
Here’s the code:
add_action($event_name, $your_function, $priority, $accepted_args);
Before diving deep into wordpress add_action function, first we need to understand wordpress do_action function.