If you do not want users to search through your website, add this code snippet to the functions.php file.

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;" ) );
Source: https://themeisle.com/blog/code-snippets-for-wordpress/
 

Leave a Comment

You must be logged in to post a Review.