Last active
March 7, 2016 16:29
-
-
Save tbcorr/b06a6da96a50710e5fa4 to your computer and use it in GitHub Desktop.
Short Circuit WordPress Search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'posts_request', 'tbcorr_posts_request', 10, 2 ); | |
function tbcorr_posts_request( $request, $query ){ | |
$is_admin = $query->query_vars['is_admin']; | |
$is_search = $query->query_vars['is_search']; | |
$is_main_query = $query->query_vars['is_main_query']; | |
if( $is_admin ){ | |
return $request; | |
} | |
if( ! $is_search ){ | |
return $request; | |
} | |
if( ! $is_main_query ){ | |
return $request; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment