Created
February 10, 2012 19:54
-
-
Save mjangda/1792216 to your computer and use it in GitHub Desktop.
Kills WordPress search query
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_where', 'x_kill_search_query', 10, 2 ); | |
function x_kill_search_query( $where, $query ) { | |
if ( ! is_admin() && $query->is_main_query() ) { | |
// this is a self-removing callback | |
remove_filter( current_filter(), __FUNCTION__, 10 ); | |
if ( $query->is_search() ) // only kill the main query | |
$where = ' AND 1=0 /* Query killed */'; | |
} | |
return $where; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment