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 Don't forget to subscribe via email so you never miss a post! You can also follow us on Facebook and Twitter!
How to Disable Search Feature in WordPress
5 (100%) 3 votes

(Visited 38 times, 1 visits today)

About the Author: Editorial Staff

Editorial Staff at the WPChandra is a team of WordPress experts writing about WordPress Tutorials, Themes, Plugins, Guides, Tricks and much more...

Leave a Reply

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