1. Home
  2. WordPress Tutorials
  3. How to Remove the Search Feature in WordPress

How to Remove the Search Feature in WordPress

Do you want to remove the search feature on your WordPress website? The search feature is a very powerful tool that can help your visitors find exactly what they are looking for. The search feature does not work seamlessly with every theme. In fact, it can actually cause problems with your current theme and make your website look worse.

The search feature has many advantages associated with it, which is why many websites are quick to add one. Unfortunately, many of these websites are just starting out and do not have enough content to take advantage of the benefits. Today, I will demonstrate how to remove the search feature in WordPress using two methods.

Why Remove the Search Feature in WordPress

The search feature is great for websites that have a lot of content stored in their archives. As time passes, it becomes increasingly harder to find older content when new content is added. The search feature allows you to directly search for keywords, products, or content titles and have the entire website searched. This is extremely beneficial for larger websites that have been around for almost a year. Unfortunately, this feature may clash with your current theme, resulting in an inferior looking website.

Furthermore, many business owners will create a simple website to display their deals, location, and hours. These websites are a prime example of the kind of websites that does not need a search feature. There is simply nothing for visitors to search for! This is what you need to ask yourself before adding the feature. Of course, the feature may not be there because you added it. Many premium themes add extra functionality to their themes to make you feel like you are getting your money’s worth. Just because the option is there does not mean you need to use it.

How to Remove the Search Feature in WordPress

Today, I will demonstrate how to remove the search feature in WordPress using two methods. The first method will be using the Disable Search plugin to remove the search feature. While the second method is to manually disable the search feature by editing your theme’s functions.php file. Keep in mind that if you choose to use the second method, you need to make sure you have access to your cPanel’s login information, which is provided by your web host. If you are not comfortable editing code I would recommend using the plugin method, but both will have the same result.

Let’s start by going to the plugins area of WordPress and click on the “Add New” button.

click on the "Add New" button.

Search for Disable Search in the available search box. This will pull up additional plugins that you may find helpful.

Search for Disable Search in the available search box.

Scroll down until you find the Disable Search plugin and click the “Install Now” button and activate the plugin for use.

click the "Install Now" button

Unlike other plugins, the Disable Search plugin works after activation. There are no settings to configure. Take a look at your website and you will notice the search feature has been removed. Keep in mind this will not remove the search feature in the admin area of WordPress, but that is only for admin view anyways.

The second method is a bit trickier since you need to edit some code, but don’t worry, anyone can do it. Start by logging into the cPanel and clicking on the File Manager option. The File Manager will allow you to access all of the files related to your website.

Click on the File Manager option.

You need to locate your theme’s functions.php file. Click on the public_html directory, then click on the wp-content folder. Inside of this folder, you will find all of the content related to your website. Click on the themes folder and enter the folder of the theme you are currently using. Finally, right-click on the functions.php file and select the Edit option.

Select the "Edit" option.

A pop-up window will show up. This box will warn you to create a backup of your files before editing anything. This will ensure that you can revert your website back to when it was working if something goes wrong. Click on the “Edit” button. A new tab will open containing all of the code from the file.

Click on the "Edit" button.

Scroll down to the bottom and insert the following lines of code:

function disable_search( $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’, ‘disable_search’ );
add_filter( ‘get_search_form’, create_function( ‘$a’, “return null;” ) );
function remove_search_widget() {
unregister_widget(‘WP_Widget_Search’);

add_action( ‘widgets_init’, ‘remove_search_widget’ );                                       

This code will hide the search bar on your website and any searches will be directed to a 404 page. Once you have inserted the code into the functions.php file, click on the “Save Changes” button to finish.

Click on the "Save Changes" button.

Congratulations, you have successfully learned two ways that you can remove the search feature from your WordPress website. Make sure to adjust how your pages look with the search bar missing. Something may accidentally be shifted up to where the bar was or create an overlap.

Less is More

Many beginning websites rush to copy successful websites. While this is not a bad thing, you need to be careful. Popular websites are not a result of luck and every feature they add has a purpose. In most cases, popular websites are not new and have been around the block, which means they have a lot of older content. The search feature is extremely useful for them, but it does not have a place on a website just starting out.

Think about that small business that has some products, location, and hours posted on it. This is extremely common and there is absolutely nothing wrong with it, but there is nothing a visitor needs to search for. In contrast, an older website will probably have plenty of content to share with visitors. Examine and think about every feature a website offers and question why it exists in the first place.

Which method have you chosen to use to disable the search feature?  Do you think every feature should be meaningful or are more features better?

Author: Chris Racicot

Chris is the Support Manager at GreenGeeks and has been with the company since 2010. He has a passion for gaming, scripting and WordPress. When he’s not enjoying his sleep, he’s working on his guitar skills and fiddling with 3d printing.

Updated on January 8, 2018

Was this article helpful?

Related Articles

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.