[WordPress] Adding filter to “the_title” “the_content” hook without affecting other in WordPress

Hello guys I am just writing this because I think this can help people who are struggling to get a way to hook filter to “the_title” and “the_content” without affecting menus and others functions in which are using the_title hook in WordPress .

While i was working on one of my new plugin name “Wp-inline-edit” which I required only to hook filter to the_title and the_content without affecting other functions but I couldn’t find a good way on WordPress support.

While Finding in after some hours of struggling I found “in_the_loop()” method, this worked but this was affecting the link of prev post and next post which was under the loop so this didn’t work for me to I only want to affect the title which is printing by the_title() function.

So after few hour of struggling and experiments I wrote one fix which can solve this problem.


How does this will work ?
Its simple!.
Check this out!.


Place this in your function.php and check it.

What does this “are_we_in” function check for ?
“are_we_in” first get the debug details which functions run before from current then check if “the_title” or “the_content” function was runs or not.





Share this Post :

No comments yet.

Please Post Your Comments & Reviews

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