How to Disable the Search Feature in WordPress

What is the WordPress search feature

As you know these days, WordPress has become one of the most global used platforms in developing websites. What is the reason of the WordPress great popularity around the word? It may be because of offering robust functionality and multiple capabilities to website developers, and then it is obvious for the platform to grow so greatly and became popular with lots of web developers. However, there are some certain difficulties with it, some several features that have troubled web developers, just like the search feature in the platform which is not working well. Usually the search feature in WordPress, I mean the default one, does not play any useful role. The Search Feature in WordPress often fails in finding the relevant results to show visitors. In WordPress Different Themes feature their different template files. In some of them a search.php template file is included, which is not a Search Page indeed, it is somehow a template for displaying search results. Also some themes include a template file called searchform.php, which is a template file often included in the sidebar of lots of themes, this template file generates the search box form, but it is not also useful. Although there is a built-in search feature in WordPress, it is not quite useful. That’s why most website developers try to remove the Search Feature in WordPress in order not to see the search box and may some look for alternatives and add Google site search or other search facilities on their WordPress site. When you remove built-in search feature your website will be cleaned up and you can offer a better user experience for visitors of your website.

A question may come to you that when I can just hide the search bar from my website theme settings or with CSS, why should I remove the WordPress search feature? Well, let us to see the problem more detailed, the problem with the WordPress search feature is; “although it can be removed in the design formally, but the functionality would not go away, it would stays. And if someone knows that your website is using WordPress, it is possible for them to simply add a “/?s=keyword” and search your website. So if you just remove the form and do not do anything for the functionality, you cannot take care of that problem.

Who wants to disable the Search Feature in WordPress? And why to do that?

  • Maybe you do not need the search feature because your website is a simple one, or your business is just a part of a growing community of the one-page websites or maybe the theme settings does not allow you to remove search feature.
  • Some website developers may disable search features in WordPress because they think that it can interfere with the user experience.
  • There are lots of company websites that use WordPress in order to use for their landings and also their information pages. Additionally, there are some single-page sites using vertical navigation which are growing in popularity. On such websites, the content is static and it is not updated regularly, such a search feature on the website in most cases would be superfluous. Also, in such websites with static content, the search string can be misleading, because noting the search box the visitor will assume that there are so many other additional information and different pages on the website which are hidden somewhere in the bowels of the website. While these websites do not have so much content, and this makes a search form an extra feature and not a useful one.
  • There is a good reason for disabling the Search Feature in WordPress and removing the search box with WordPress, and the reason is to replace the search box with a different useful search box, such as Google Custom Search or some other searching facilities.

So, for whom is it helpful no to remove the Search Feature in WordPress?

There is a place where the Search feature in WordPress is useful and it is just on websites offering materials which are updated and published in a regular manner, let us say like blogs.

Disabling the Search Feature in WordPress

There are two ways to disable the Search Feature in WordPress, you can Disable Search Feature in WordPress using a plugin, or you can remove the search feature in WordPress with code snippet. Both will be described as follows:

A) Disabling the Search Feature in WordPress Using a Plugin

This method is so easy and it is recommended for all website developers especially for who is order to use the plugin method you just need to install the Disable Search plugin and activate it. See our page on how to install a WordPress plugin.You can search the plugin and install it.This plugin is working out of the box and you will not need to configure any setting. After you activated the plugin, the plugin will remove the search feature form your WordPress theme and also will disable the search widget. This way when some visitors of your website directly try to enter a search query URL, this plugin will return a 404 error page them.
This plugin has no affect searching functionality inside the WordPress admin area and you still have the possibility to search your posts and pages inside your WordPress admin area.

B) Removing Search Feature in Word Press via code Snippet

You just need to copy a code in your website theme’s functions.php file. Easily you can find the functions.php file in tracking this path: WordPress Admin Dashboard > Appearance > Editor, then find the file functions.php and copy the below code in, you can also access the same via FTP. Now copy the below code at the very bottom of the file “functions.php”. Beware, if there is a sign of “?>”, paste the code above “?>” sign.

The code is:

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’ );

Via this code you will simply direct all search queries to a 404 page and no searching will be done. And the search box will be also removed from your WordPress theme.

Thanks God and all people sharing their knowledge and skills for all these facilities.

Leave a Reply