2 Ways To Remove WordPress Search From Your WP Powered Site

Many WordPress sites are simple business websites with just a few pages. Removing search feature in such cases will eventually clean up the website, freeup some spaces and offer a better user experience.

WordPress Search Box

The WordPress search feature helps to navigate and locate posts easily. But sometimes your site does not need the search feature; and retaining the search form in your WP theme in such case may interfere with user experience.

In this article, you will learn how to easily disable the WordPress search feature from your WP powered website.

So, let’s consider the first option on how to remove the search feature from your WordPress website with ease:

1. How to Disable WordPress Search Manually

This option is most preferred if you can update the function file without issues. It only requires a piece of PHP code to be inserted into the WordPress function file.

You will need to add the following code to your theme’s functions.php


function wpsc_filter_query( $query, $err = true ) {
	if ( is_search() ) {
	$query->is_search = false;
	$query->query_vars[s] = false;
	$query->query[s] = false;
	if ( $err == true )
	$query->is_404 = true;
	}
}


function remove_d_widget() {
    unregister_widget('WP_Widget_Search');
 
add_action( 'widgets_init', 'remove_d_widget' );

add_action( 'parse_query', 'wpsc_filter_query' );
add_filter( 'get_search_form', create_function( '$a', "return null;" ) );

2. Removing WordPress Search Feature Using a Plugin

First thing you need to do is install and activate the Disable Search plugin. The plugin actually works out of the box, without any settings for further configuration.

Upon activation, it will remove the search form from the active WordPress theme and in likewise, disable the search widget. If a user directly tries to enter a search query URL, the plugin will return a 404 error page.

With this plugin however, you can still search posts and pages within the WordPress admin.

MORE TO READ:

01: How To Enable Or Disable Google AMP In WordPress

thanks for the update…. Its been long time. How are you guys?
I love wp search, but its good to know some good reasons to disable it.

2 Likes Like Quote Report
2 Likes Like

Thanks @sly and thanks once again for stopping by….

0 Like Like Quote Report
0 Like Like