Site icon Hip-Hop Website Design and Development

How to reset/remove added filters ‘posts_join’ and ‘posts_orderby’ after the loop is completed?

I am sorting results appear on the category archive page using these filters: posts_join and posts_orderby. There is a widget, which displays recent posts. I am using default recent posts widget of WordPress. But it’s not showing any result. When I investigated I found that the applied filters are getting applied to this query. So, I tried remove the filters using the following code:

remove_filter('posts_join', 'my_filter_join');
remove_filter('posts_orderby', 'my_filter_orderby');

But still it does not work.

I also tried to put the following code in the filter functions itself:

// Disable this filter for future queries!
remove_filter(current_filter(), __FUNCTION__);

It does not work either.

How to fix this issue?