I would like to disable the MySQL portion of the main query, i.e. I want every step to be followed on this page EXCEPT step 4.3: http://codex.wordpress.org/Query_Overview
What’s the easiest way to go about doing that?
I would like to disable the MySQL portion of the main query, i.e. I want every step to be followed on this page EXCEPT step 4.3: http://codex.wordpress.org/Query_Overview
What’s the easiest way to go about doing that?
Comments are closed.
Check if this solution work for your case:
posts_request
is the last filter called before running the query, and pass to you the$request
variable with the generated SQL string and$query
, with the WP_query object used to generate the query.This way you can check if this is the main query, and return false to don’t run the generated query.
It typically hard to throw out completely thing that WP insist on doing during core load process. It is however relatively easy to mess with them in smaller ways and sufficient results.
Query has a lot of filters, namely
posts_where
(withis_main_query()
check to be sure we are only modifying it) allows us to changeWHERE
part of SQL query.But what do we add to it to get rid of it? Typically following condition is used
AND 1=0
. Since it’s very obviously not satisfiable it efficiently short circuits SQL query into no results.