WordPress Actions Filters, and Hooks

WordPress Hooks

hooks WordPress Actions Filters, and Hooks

WordPress Hooks allow developers to easily write their own code in with the WordPress core code base, themes, and plugins.

Actions and filters allow us to add our own functionality or modify your site’s behaviour by hooking a callback function onto a specific tag in the core code, setting priorities and using parameters and arguments passed to the callback function. hooks also useful for making plugins in wordpress create a plugin using hooks

There are two types of hooks:

1.Wordpress actions

An Action in WordPress is a hook that is triggered at specific time when WordPress is running and we take an action. This can include things like creating a widget when WordPress is initializing or sending a Tweet or post when someone publishes a post.

Structure of action :


To add a piece of code to execute or to “hook” when WordPress publish a post. All what you have to do is this:


add_action is a WordPress function used to register another function to be executed at the save_post hook which is the first parameter and the function name to be executed as the second parameter.

2. WordPress filters.

A Filter in WordPress allows you get and modify WordPress data before it is sent to the database or the browser. Some examples of filters would include customizing how excerpts are displayed or adding some custom code to the end of a blog post.

Structure of filter


The filter which we should use in this case is the_title. You can find a list of the pre-defined filters hooks in the WordPress codex. All relevant links are listed below.


add_filter is a WordPress function used to register a filter to be executed on the_title hook attached to the $post_title variable, and the function name to be executed as the second parameter.

The Difference Between Actions and Filters

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

WordPress Hooks 1 WordPress Actions Filters, and Hooks

How to Unhook from Actions and Filters

To remove a hook is preety simple. Use the function remove_action or remove_filter along with the name of the hook, function, and priority. Priority is optional if you have to unhook a function that is hooked more than once and you only want to remove a specific occurrence of that function.

Remove previous understand actions use below code:


if we need to remove above showing filter simply we need to write this line

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face – we are here to solve your problems.

I, Dayanand Saini,the founder and chief editor of www.webtechsource.com,have been working as a software engineer from last 4+ years. It's my hobby to learn new things and implement on live environment.

One Reply to “WordPress Actions Filters, and Hooks”

Leave a Reply

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

3 + 6 =

%d bloggers like this: