Learn how to disable the WordPress search feature in this quick guide.
The wordPress search feature is really useful, but you might easily come across a situation where you want to remove the default search feature.
Recently one of our clients asked us to remove the default search of WordPress from their front end. As I started to explore options, I was surprised to see so many other users looking to do this.
If you too wanted to remove the default search code for WordPress search here’s how to do it.
Steps to Disable WordPress Search With Plugin
We will make use of the popular disable WordPress search plugin available to download for free from the WordPress repository.
Follow these steps to disable WordPress search feature with a popular Disable Search plugin.
- From your WordPress dashboard, go to Plugins > Add New and search for Disable Search plugin.
- Install and activate the Disable Search plugin from WordPress plugin repository.
- Once activated, the plugin should disable the built-in front-end search capabilities of your WordPress blog.
It’s important to note that the plugin only disables search on the front-end of your WordPress website. If you still see search boxes, it might be because of the theme you are using.
This plugin will, however, ensure that the search function from those boxes is disabled.
Editing Code to Disable WordPress Search
As I continued to look for manual options, I found that WPEngineer had a solution by adding few lines code.
Follow these steps only if you are comfortable editing your WordPress theme files. This is not recommended for WordPress beginners.
- First, go to your WordPress Dashboard and navigate to Appearance >> Editor
- Now open your theme’s functions.php file.
- Add the following code to the file.
Please note that if you set
$error to be true in the above code, then the user will be redirected to your 404 page. So you must have your theme’s 404.php. If you set it as false, then the user stays at the page where they tried to run the search.
Have you disabled the search feature in your blog? Let me know in the comments below.