Skip to content

Instantly share code, notes, and snippets.

@fangcat
Created July 24, 2014 12:53
Show Gist options
  • Save fangcat/bfd4aa362c0e8dc49e8f to your computer and use it in GitHub Desktop.
Save fangcat/bfd4aa362c0e8dc49e8f to your computer and use it in GitHub Desktop.
停用WordPress內建搜尋功能
/** Disable WordPress Search **/
function fb_filter_query( $query, $error = true ){
if ( is_search() ) {
$query->is_search = false;
$query->query_vars[s] = false;
$query->query[s] = false;
// to error
if ( $error == true )
$query->is_404 = true;
}
}
add_action( 'parse_query', 'fb_filter_query' );
add_filter( 'get_search_form', create_function( '$a', "return null;" ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment