How to Disable WordPress Search Feature

Disable-WordPress-Search-Feature-Tutorial

Learn how to disable WordPress search feature in this quick guide.

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 the 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.

Disable Search WordPress Plugin Download

Follow these steps to disable WordPress search feature with a popular Disable Search plugin.

  1. From your WordPress dashboard, go to Plugins > Add New and search for Disable Search plugin.
  2. Install and activate the Disable Search plugin from WordPress plugin repository.
  3. 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.

  1. First, go to your WordPress Dashboard and navigate to Appearance >> Editor
  1. Now open your theme’s functions.php file.
  1. 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.

Pradeep Singh

Pradeep Singh

Pradeep Singh is the founder and your host here at WPism. He is an entrepreneur and blogger living his startup life based in London and Cambridge. Follow him on Twitter or like his page on Facebook.
Share on reddit
Share This Article
Share on facebook
Facebook
Share on linkedin
LinkedIn
Share on twitter
Twitter

4 Responses

  1. In my primary domain I had one WP installation for the blog, but I needed also a section for landing/squeeze/thanks pages, and I wanted these pages not to be easily discoverable. So, I opted for a second WP installation with all the flags and whistles off (pingback/trackback, update service, feeds, search results). Thanks to your article I put together the final piece of the puzzle – search results. Thank you. 🙂

  2. Using your code changed the look of my site. Can you please help? I have no idea where exactly the code should go to work properly.

Leave a Reply

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

Join our list

Our Exclusive Deals

Share this post

Share on facebook
Share on twitter
Share on pinterest
Share on linkedin
Help us share this post with your network?
Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn
Share on email
Email
Want to keep updated with WordPress?

Join our monthly newsletter to receive best curated WordPress resources.

Want to keep updated with WordPress? Join our monthly newsletter.