apply_filters( 'relevanssi_prevent_default_request', boolean $prevent, WP_Query $query )
This filter hook controls whether the default WP search request is blocked or not.
(boolean) If true, block the default request.
(WP_Query) The query object.
When a user performs a search, WordPress does a query to get the posts. Relevanssi active, that query is unnecessary, as Relevanssi performs a different query, and the results from the WordPress default query are unnecessary. To save resources, Relevanssi changes the default WP query to
SELECT * FROM $wpdb->posts WHERE 1=2
Which, of course, returns nothing and WordPress wastes no resources on this unnecessary query.
There are some cases where you may want to block Relevanssi from interacting with a specific query. In that case, you need to do two things: you need to stop the Relevanssi query from running and stop Relevanssi from blocking the default query. This filter hook is one half of that. If you want to block Relevanssi completely, you don’t have to worry about this filter hook; unhook the whole function:
remove_filter( 'posts_request', 'relevanssi_prevent_default_request' ); remove_filter( 'posts_pre_query', 'relevanssi_query', 99 );
You need this filter hook if you want to block Relevanssi from specific queries selectively. Here are some real-life examples: