Do you want to disable the search feature in WordPress?
Sometimes, your site may not need the WordPress search feature, or the search form in your theme may interfere with the user experience.
In this article, we will show you how to easily disable the search feature in WordPress.
Why and Who Should Disable Search Feature in WordPress?
WordPress websites come with a search function that lets visitors look for content within your website.
Many WordPress websites are simple business websites with a few pages. There is also a growing trend of one-page websites with vertical navigation.
These websites do not have much content, which makes a search form pointless. It also gives users the impression that there might be some other information that they can’t see and can find through a search.
Removing the search feature will clean up your website and offer a better user experience.
That being said, let’s take a look at how to easily remove the search feature from your WordPress site:
Method 1. Remove Search Feature in WordPress Using a Plugin
This method is simple and straightforward.
First, you need to install and activate the Disable Search plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.
Upon activation, the plugin will work immediately. There are no settings for you to configure.
It will remove search forms from your WordPress theme and disable the search widget. If a user directly tries to enter a search query URL, then the plugin will return a 404 error page.
Note that this plugin does not affect the search functionality inside the WordPress admin area. You can still search posts and pages inside your WordPress dashboard.
Method 2. Disable Search in WordPress with Code
This method requires you to add custom code to your site’s WordPress core files. If you haven’t done this before, then take a look at our guide on how to add code snippets in WordPress.
Normally, we don’t recommend editing your WordPress files directly, as even small things can break your site. However, we will be using WPCode, which is the safest and easiest way to add code to your WordPress site.
First, you will need to install the free WPCode plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.
Upon activation, you will need to find Code Snippets » Add Snippet in your admin dashboard.
Then, you just need to type ‘disable search’ into the field and then click on ‘Use snippet.’
You will now be taken to a screen where all the settings to run this code snippet have already been configured.
All you need to do is toggle the switch to ‘Active’ and click ‘Update.’
This code will prevent search queries and remove search forms from the front end, the search block from the content editor, and the admin bar menu search box.
Users who have access to the site’s admin dashboard, however, will still be able to search through posts, pages, and comments from there.
Bonus: Disabling Blog Features in WordPress
Besides the search bar, you may also want to disable the blog features in WordPress. If you have a simple one-page website, then you won’t need to showcase a blog.
For example, a lot of online stores, online portfolio sites, or membership websites may not have use for blogging. While you can build your WordPress website without using the blogging features, they’ll still remain visible within the admin area.
All you need to do is download the Disable Blog plugin, which will hide the post type along with all blog-related settings and admin pages.
Upon activation, the blog automatically removes the ‘Post’ settings from the left-hand menu of the admin sidebar. For more details, check out our tutorial on how to easily disable blog features in WordPress.
We hope this article helped you learn how to easily disable the search feature in WordPress. You may also want to see our beginner’s guide on how to add Google search in a WordPress site and our expert pick of the best search plugins for WordPress.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Steven
Line 11 of method 2 was not hiding the search form for my installation, but makes the default form appear, which is loaded / generated by general-template.php’s function get_search_form (at least WordPress 5.4.2).
The function applies the filter get_search_form. In case the filter returns null (null === $result, line 299), the previously loaded or generated default form will be shown or returned.
To hide the form, I had to change line 11 needs to return an empty string:
add_filter(‘get_search_form’, function ($a) { return ”; });
lee maupa
i have the same problem in that im failing to access the customization nav and iv tried to make changes in the code but not getting any joy. i have tried to install the plugin but still the search still appears. please some one help how to resolve this issue.
which folder/file do i get the header menus maybe i can remove it from there, please assist
WPBeginner Support
That can vary from theme to theme where the file is after you to into your wp-content/themes/theme name file. Some themes have a header.php while others have the code in another location. If you reach out to your theme’s support they should be able to assist.
Admin
Sherell
Thank you for posting this! I was filling my site with all kinds of crazy codes I was finding on the internet in hope of getting rid of that doggone search box! Now everything is good!
WPBeginner Support
Glad our article could help
Admin
Jeff Cohan
Thanks for this. Very useful.
A few comments:
1. Method 2 (manual) works for me (i.e., removing search box) on a child theme of twentyeleven, but only for a search *widget* added to a widget area. It leaves the search box that is hard-coded (using get_search_form()) into header.php. I know I can override the parent theme’s header.php by cloning/editing it, but I’l like to know how to disable that search form programatically.
2. I cannot get Method 2 to work on a Genesis theme. I wonder if you or anyone has some insights here.
3. A little thing: the method 2 script needs a closing brace on line 14.
WPBeginner Support
Thank you for letting us know about the closing brace, we’ll be sure to update it
Admin
Toddp
Ok it removed the search box but left the search title that we must now figure out how to remove.
DO you have an plugin for that?
Seems to me you would have an option like this already installed in the site builder.
Samantha
Sometimes you can disable the search feature for example, on an one page site that does not really need a search feature.
tina alfieri
hi,
I want to remove the search box completely on my home page. How do I do this please?
Tati
Thanks for the article. What I need to know is: can I disable only some terms of the search and keep the search function working? I want to exclude things like /?s=d, download, thank, success, congratultions… terms that hackers use to find specific pages inside our sites.
Can someone help me with this? TIA
Silvana Donato
Thank you very much.
I have just been hacked in the database of one of my websites and I have removed all the possible gates to these terrible annoying people, who have nothing to do in life but distroying other people work.
So I removed the search forms but i did not know how to remove the query string.
Gary C
Another reason for disabling the search box that comes with WordPress is to replace with a different search box, such as Google Custom Search.
Google Custom Search allows you to monetize your search pages provides you have an Adsense account.
Editorial Staff
Was not aware of this. Thanks for letting me know.
Admin
George Stephanis
Yup. There’s also __return_true __return_false __return_zero and __return_empty_array
http://core.trac.wordpress.org/browser/trunk/wp-includes/functions.php#L3329
W3Mag
Heh! Thanks for the tips I was looking to do this at one moment and had no clue on how I can do it!
Steven Bradley
I’m having a hard time understanding the usefulness of this code. If search is unnecessary wouldn’t it make more sense to not include the search form? If you leave a search form on a page and then don’t let someone use that search form isn’t that very poor usability?
Am I missing something?
Editorial Staff
You can remove the search form in the design, but the functionality stays. Anyone who knows it is WordPress can simply add a /?s=keyword and search the site. But by removing the form and adding this code will take care of that problem. There will be time when you have a client that only wants pages or posts to be shown if the URL is available. This function will come handy in that sense.
Admin
Toddp
Yes it makes more sense to leave out search and other widgets and allow the customer to add them if they want them and not put them by default.
Marc T
Hmmmm…. can’t imaging Search not being important for a CMS. Isn’t the fact that WordPress has such a fine Search feature a huge advantage when using it as a CMS? I can imaging Search only being not important on a small portfolio site say limited to 5 pages or so.
Editorial Staff
There are times when you are using WordPress to create a standalone site for a client where you only want people to know about the pages if they have the URL.
Admin