How to Disable WordPress Search Feature

How to Disable WordPress Search Feature

Search feature comes by default in WordPress. WordPress provides a search widget for this. And also WordPress defined a page template and a form for this. Which you can customise as per your requirement. But what if you want to disable WordPress search feature?

Sometimes your site not has need for search functionality. Or you don’t want the search for better user experience. In this post, we learn to disable the WordPress search system.

Why disable WordPress search Feature?

Assume you are using a WordPress site which has a login system. Means some of the pages will be visible to only logged-in users. If such website enabled search feature, then there will a chance to find these login page in search results.

In above case, your site does not need to have the search feature. So you can disable search feature on WordPress website.

How to disable WordPress Search feature?

Now you get who should disable search feature. Now how can one disable WordPress search feature? It’s very simple to do that. So let dig into this.

Disable WordPress Search feature via Plugin

I love WordPress because of plugins. You can get any type of plugins for free. Similarly, there are a plenty of plugins available on WordPress Plugin repository to disable search feature.

disable search free wordpress plugin - How to Disable WordPress Search Feature

Source: Plugin Page

Disable Search is one of the free plugins that help you to disable search feature form your WordPress site. Once you install and activate the plugin. You site no more have the search feature. This plugin not required any additional setting.

Once you activate Disable Search plugin, search widget from widget library will remove. If you directly add search query URL, then the site will show an error page(404 page).

Disable WordPress search feature via Child Theme

If you are using WordPress for a while, you should know about the child theme. Using child theme for customization is the best way to not lost changes on theme update. It needs some code customisation, so you can say it Manual method to Disable Search Feature in WordPress.

For this, create a child theme for your active theme. Add below code in child theme’s functions.php file.

function ds_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', 'ds_filter_query' );
add_filter( 'get_search_form', create_function( '$a', "return null;" ) );
function ds_remove_search_widget() {
add_action( 'widgets_init', 'ds_remove_search_widget' );

This function will generate 404 error when a search query in rendered. While unregister_widget is used to disable the search widget.


This is how you can remove search feature from your WordPress site. Removing search feature is good for those, who use a business website with a low number of pages. Hope you like this tutorial. If you have any query related to WordPress search feature, comment it.

Subscribe to this blog to get latest post direct into your inbox.

Share the Article

About author
Darshan Saroya

Darshan Saroya

A passionate WordPress Theme Developer. I love to create clean and modern themes, using the power of WordPress. Here I provide the tutorials related to WordPress Development, Core PHP and HTML.