Skip to content

Instantly share code, notes, and snippets.

@tbcorr
Last active March 7, 2016 16:29
Show Gist options
  • Save tbcorr/b06a6da96a50710e5fa4 to your computer and use it in GitHub Desktop.
Save tbcorr/b06a6da96a50710e5fa4 to your computer and use it in GitHub Desktop.
Short Circuit WordPress Search
<?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