How to Disable the Search option in WordPress

Search is the important feature of any large website because they have lots of content and visitors can easily search the desired content using search feature. This makes the website performance much better because visitor don’t have to to search the content step by step. This decreases the bounce rate because visitor finds the right content in short time so that they can spend more time on the content they are looking.

But sometimes, your website have little content. Also, there are a number of websites which has all their content on a single page. Those websites don’t need any search button because their visitors don’t have to search other pages as there is an only single page. Having search feature on those websites can mislead the visitor as they think there will be more content on the website which they can search. So there is a need to disable the search feature for those website. In this article, we will show how we can disable search feature in WordPress.

There are two methods of removing the search feature:
1. Using a plugin.
2. Manually disable the option.

1. Remove Search Feature in WordPress Using a Plugin

This is the best way for beginners who don’t have much knowledge of coding. First thing you have to do is to install and activate Disable Search plugin. For more details, read our previous article on how to install and activate plugin in WordPress.

There is no setting page for the plugin. As you activate the plugin, it simply disable the search feature for your website. If a visitor enter a search query, it will be redirected to 404 error page. The plugin disable the search feature for visitor.

2. Manually disable the Search option.

If you have knowledge of coding, then you should go with this method. Because use of extra plugin may affect the performance of your website. You have to add a simple code in your site theme file.

You have to paste this following code into your theme’s functions.php file:

function wpb_filter_query( $query, $error = true ) {
if ( is_search() ) {
$query->is_search = false;
$query->query_vars[s] = false;
$query->query[s] = false;
if ( $error == true )
$query->is_404 = true;
add_action( 'parse_query', 'wpb_filter_query' );
add_filter( 'get_search_form', create_function( '$a', "return null;" ) );
function remove_search_widget() {
add_action( 'widgets_init', 'remove_search_widget' );

You can also paste this code into any site-specific plugin. For more details read our previous article how to create a custom plugin in WordPress.

This procedure also does the same process. All the search queries are redirected to 404 error page. Also, the search form is disabled.

We hope you like this article. If you have any query, you can ask in below comment box.

You can also check How to Turn Off Trackbacks and Pingbacks in WordPress.

Spread the love

Kapil Garg

Kapil Garg has 7 years of experience in building professional websites. He is a leading web developer, web designer and Google adwords certified partner. His passion is to designed and developed most impressive websites.

Leave a Reply

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