Today we are going to discuss two wordPress functions current_filter and doing_filter. You can learn other wordPress functions in previous blogs. If you check our previous blogs on wordpress hooks then you can get the clear idea of it. We will review both the functions with syntax as well as with example so we start with the remove_filter function. Please have a look.
remove_filter
remove_filter removes the attached callback function with mentioned hook and you can check the callback function with its priority to remove. It takes three parameters. Please have a look.
Syntax |
remove_filter( $hook_name, $function_to_remove, $priority ); |
Return value |
True/False . Value will be true if callback function for assigned filter is removed otherwise value will be false |
Parameters |
Description |
$tag(string) |
This is required one. Function attached with this hook will be removed. |
$function_to_remove(string) |
Pass the callback function to be removed. This is also required one. |
$priority (int) |
Pass the integer to match the priority with attached callback. This is an optional one.
|
This method is useful to remove the callback with different checks like function name,priority etc. Now we will take a small example.
remove_filter( 'the_title', 'extra_title' );
remove_filter( 'the_title', 'extra_title', 2);
In above example, We are removing callback function with priority and without priority.
remove_all_filters
remove_all_filters is wordPress function to remove the all the callback functions attached with mentioned filter. It is useful to remove all hooks with one call. You can set the check for priority as well.
Syntax |
remove_all_filters( $tag, $priority ); |
Return value |
returns True/False. |
Parameters |
Description |
$tag(string) |
This is required one. Name of filter to remove the attached hooks. |
$priority(int) |
This is optional and remove with mentioned priority. |
remove_all_filters('the_title');
remove_all_filters('the_title,3);
In above example, we are removing hooks for mentioned filter with priority and without priority. Thank you for being with us.
0 Comment(s)