From a2354483d1b4049423466bd3a1dca70b256530ae Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Sat, 27 May 2017 19:24:54 -0400 Subject: [PATCH] Suppress main query --- functions.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/functions.php b/functions.php index 3478cf3fb..68efb4c59 100644 --- a/functions.php +++ b/functions.php @@ -355,6 +355,22 @@ function dones_register_custom_types() { } add_action( 'init', 'dones_register_custom_types' ); +/** + * Suppresses main query, since we don't use it. + * + * @param string $request The complete SQL query + * @param WP_Query &$this The WP_Query instance (passed by reference) + * @return string|bool $request The complete SQL query, or false if main query + */ +function dones_disable_main_query( $request, $query ) { + if ( $query->is_main_query() ) { + return false; + } + + return $request; +} +add_action( 'posts_request', 'dones_disable_main_query', 10, 2 ); + /** * Removes the Done Tags column from the manage (admin) list view */