WordPress search feature is useful. You might come across a situation where you want to remove the default search feature. Usually, business websites do not have much content. There is no requirement of the search feature in this kind of websites.
Due to that feature, users may think that there might be some other information that they can’t see. Removing the search feature will offer a better user experience. In this article, we will show you how to easily disable the search feature in WordPress:
1. Disable WordPress search with the plugin
Using plugin is a very easy method. Most of the WordPress users use a plugin to disable the WordPress search feature. The first step is to install and activate the plugin called Disable Search.
There are no settings for you to configure in Disable Search plugin. After activation, the plugin will remove the search form from your WordPress theme and disable the search widget.
If the user tries to enter a search query URL, the plugin will return a 404 error page.
The plugin only disables search on the front-end of your WordPress Website. You can still search posts and pages inside your WordPress admin. If you still see search boxes, it might be because of the theme you are using. The plugin ensures that the search function from those boxes is disabled.
Apart from the Disable Search Plugin, you can edit the code to disable WordPress search. You can disable the search option by adding a few lines of codes.
2. Manually disable search feature in WordPress
In this method, you have to add code to your WordPress files. First, go to the appearance in your WordPress dashboard and click on editor. Next, open your theme’s functions.php file. You will need to add following code to your theme’s functions.php file or a site-specific plugin:
This code will redirect all direct or indirect search queries to a 404 page. This code will hide the search form in your WordPress theme. If you set $error to be “true” in the above code, then the user will be redirected to your 404 page. You must have theme’s 404.php. If you set it as “false”, the user stays at the page where they tried to run the search.
We hope this article will be useful for you and you will be able to disable search feature successfully.