WP Query filters active on wrong query

I’m running several filters on WP_Query on a specific query, simply because I had to. I add these filters right before I run the query and remove them inside the callback functions. The Query Monitor plugins shows that the filters aren’t active but as soon as I run a regular WP_Query elsewhere in my code the generated SQL query shows me that the filters are actually still added, breaking basic WP_Queries.

An example of one of the filters is

public function add_select_views($select) {
remove_filter( current_filter(), __FUNCTION__, 20);
$select .= “, SUM(views.count) as totalviews”;
return $select;

Does anyone have any idea why the filters are still added to my ‘regular’ WP_Query?

Addition: These filters are added in REST endpoints, if that matters at all.

Read more here:: WP Query filters active on wrong query

Leave a Reply

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