Some websites might not really need the search feature, or maybe it could actually harm them. You could be one of those persons who needs disabling of the search feature. This pages could include one-page websites maybe or websites that do not have much content on them.

Below we will show how to easily disable the search feature in WordPress in a couple of steps.

Use a WordPress plugin to disable search function

We would recommend this option as it is easiest to use.  For this we will need to download and install the Disable Search plugin. The plugin works out of the box, and there are no settings for you to configure which is actually great. It’s simple, easy to use and goes straight to the subject.

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

We should also say that affects only the front-end area of your website and the Dashboard UI will not be changed.

Manually Disable Search Feature in WordPress using custom code

This method requires you to add code to your WordPress files or theme files. It’s recommended that you use child themes or create your own plugin if you want to go this way. The code we need to add is:

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

We hope this is helpful for anyone looking to adapt the UX of his website to their needs. If you feel that it was useful, don’t forget to Like our Facebook Page and follow our Twitter profile.