The momentum to make a query is already at full speed by the time “pre_get_posts” fires. I suppose you could use the “query” filter to set the SQL to null
, which will cause $wpdb->query() to return false
. It’ll prevent the query, but there may be undesirable knock-on effects. Wouldn’t hurt to try and see what happens.
The practical problem will be in determining which SQL is an undesirable query and which should be allowed to proceed. You can minimize the different conditions to check for by adding this filter hook from the “request” callback so we know in general this is a search request. But there are likely other queries that still need to go through. I don’t think you can block all queries just because it’s a search request.
If that doesn’t work for any reason, I recommend consulting the Query Overview description. It describes the entire process of handling a request and determining what sort of query to make based on it. You can then dig into the source code related to the processes described to see what opportunities there are to entirely suppress the default search query.
Or just don’t use the “s” query var ??