In this code snippet we will share how to disable the search feature in WordPress. If you want to disable search feature, You need to add some line of code to your theme’s functions.php file.

Add the following code to 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;" ) );

If you feel this snippet useful? Any questions or suggestions? Do let me know your thoughts via comments.

How to Disable Search Feature in WordPress Click To Tweet

Disclosure: This post contains affiliate links. This means we may make a small commission if you make a purchase. This doesn’t cost you any more but it does help us to continue publishing helpful content – thank you for your support!

How to Disable Search Feature in WordPress
5 (100%) 3 votes

(Visited 39 times, 1 visits today)

Leave a Comment

Your email address will not be published. Required fields are marked *