WordPress action hook is really important for theme and plugin development or even in customization.

One of the feature is, it allows us to show our content in any point of any page. Which comes really handy when doing client’s project.

It can be done in two simple steps
Step 1: First declare do_action() in your view.
For example:
do_action("before_description_single");   
This means, an action will be performed which name is
“before_description_single”


Step 2: add the action from backend.
For example:
add_action("before_description_single", "before_post_description");
Here first parameter “before_description_single” is the name of action which we added in “do_action” and the second parameter is “before_post_description” is the function name where all the work is done.
Full code example can be like follow:
function before_post_description() {
echo '<a href="http://www.delowar.me">Delowar Hossain</a>';
}
add_action("before_description_single","before_post_description");
The more action_hook we use, the more customizable our theme will be.


Leave a Reply

Your email address will not be published. Required fields are marked *