Welcome to FindNerd.
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 based 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 doing_filter function. Please have a look.
A) doing_filter()
Syntax |
doing_filter($filter); |
Return
value
|
True/False . Value will be true if filter is working/applied otherwise value will be false |
Parameters |
Description |
$filter(string) |
This is optional one. It is the name of the filter to check the working. |
It will check for any filter if you do not pass the filter name as the argument. If you pass specific name then it will check for the same filter to apply. Now we will take a small example.
if(doing_filter('save_post'))
{
// write your code here
}
In above example, it will return true if save_post is triggered otherwise false.
current_filter
Syntax |
current_filter(); |
Return value |
returns hook name as string |
Parameters |
None |
function post_title() {
echo current_filter(); // 'the_title'
}
add_filter( 'the_title', 'post_title' );
In above example, we are using the_title filter and using current_filter inside the callback. Thank you for being with us.
0 Comment(s)