How To Disable WordPress Search? I got the answer from WPEngineer.com, This nice tips is will disable WordPress Search more easy and of course easy to do. Why disable WordPress search? Here some of my reason. Some time WordPress based application didn’t need this featured.
Here we go, If you set the variable $error
to true
, then you will be fowarded to the error page of the theme, if not, then you will remain on the page from where the search was started.
[sourcecode language=’php’]
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;” ) );
[/sourcecode]
This is some tips that I got and you can read more details on this post.
Leave a Comment