How to Disable the Search Feature in WordPress

How to Disable the Search Feature in WordPress

Do you wish to disable the search function in WordPress? Often your site may not require the search function and also the search form in your theme may interfere with user experience. In this post, we will reveal you the best ways to easily disable the search feature in WordPress.

Why and also Who Should Disable Search Feature in WordPress?

Several WordPress sites are simple business websites with a couple of web pages. There is likewise a growing pattern of one-page websites with vertical navigating.

These websites does not have much web content that makes search form a novelty item as well as not a valuable feature.

It likewise provides customers the impact that there might be a few other information that they can’t see and also hence the search alternative. Getting rid of search function will certainly tidy up your website as well as offer a much better individual experience.

That being said, let’s take a look at how to quickly eliminate search feature from your WordPress site.

Approach 1. Remove Search Function in WordPress Using a Plugin

This method is simpler and also is recommended for all individuals.

First point you have to do is install as well as turn on the Disable Search plugin. For more details, see our detailed overview on how you can set up a WordPress plugin.

The plugin works out of the box, and also there are no settings for you to set up.

Upon activation, it will get rid of search form from your WordPress theme and disable the search widget. If a customer directly attempted to enter a search query URL, the plugin will certainly return a 404 error page.

search404error

Note that this plugin does not influence the search functionality inside the WordPress admin area. You can still search articles and pages inside your WordPress admin.

Approach 2. Manually Disable Search Feature in WordPress

This technique needs you to include code to your WordPress documents. If you haven’t done this in the before, then have a look at our guide on how you can replicate as well as paste code in WordPress.

You will should add this code to your theme’s functions.php documents or a site-specific plugin.

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() {
    unregister_widget('WP_Widget_Search');
add_action( 'widgets_init', 'remove_search_widget' );

This code will merely redirect all direct or indirect search queries to a 404 web page. It will certainly additionally hide the search form in your WordPress theme.

searchformdisabled

We hope this write-up helped you find out ways to conveniently disable search function in WordPress. For WordPress Development ServicesSee how we can help your business grow in the digital marketplace.

If you liked this short article, after that please subscribe to our YouTube Channel for WordPress tutorials. You could likewise find us on Twitter and Facebook.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s