Remove Search from 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 Should A Website Disable the Search Option?

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 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 with your web hosting.

If you are not comfortable editing code I would recommend using the plugin method, but both will have the same result.

Method 1: Remove WordPress Search with a Plugin

Start by clicking on Plugins and selecting the Add New option on the left-hand admin panel.

Add New

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.

Install Disable search to remove that function from WordPress

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 the admin view anyway.

Method 2: Remove WordPress Search with Code

The second method is a bit trickier since you need to edit some code, but don’t worry, anyone can do it. To be extra safe, consider creating a backup before starting this method. There are a lot of great backup plugins to choose from.

Step 1: Enter File Manager

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.

Step 2: Locate functions.php File

You need to locate your theme’s functions.php file. Click on the public_html directory, then click on the wp-content folder. Inside 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.

Edit the functions.php file to remove the search option from WordPress

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.

Step 3: Enter the Code

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 to remove the search feature from WordPress

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 a small business website that has some products, locations, 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?

7 thoughts on “How to Remove the Search Feature in WordPress”

  1. Very good article, but I don’t think it deals with my requirement: to remove Search box from specific pages.
    Is this possible?

    1. Hello Frances. It depends on how you have search set up. If you add the search field to a sidebar widget, you can use something like the Widget Options plugin to hide the search on specific pages, posts, and custom post types.

  2. Hello! I just downloaded the Disable Search plugin and activated it and the search icon still appears on the upper right hand corner of my website. Do you know what I could possibly be doing wrong?

    1. You might be running a theme that has a search icon built in the template. What theme are you running? If this is the case, you will want to delete that portion of the code or override it.

  3. Hello I have built my website with Elementor, and I have not used any theme, still after installing Disable search plugin, it still showing the search bar in the top please.

    I have tried the CSS also but it doesn’t change anything can you tell me please
    I am so tired with it

    1. Hi Ashish,

      You have to be using some theme… Elementor is a page builder that attaches to any theme. You probably want to go directly to the Elementor developers for help with their page builder.

  4. hej ! i tried and it gave syntax error for : add_filter( ‘get_search_form’, create_function( ‘$a’, “return null;” ) ); I added ‘ ‘ to create_function so got rid of error message,
    never the less, it didnt disable search option,
    I am using audioman ( free not pro)

    thanks for your post anyway

Leave a Comment

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

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