How to disable the search feature in WordPress

To disable the search feature in WordPress, you can use one of the following two methods:

Method 1. Using a WordPress Plugin

If you’re using WordPress to power a simple site, like a single landing page for your brand, business, or organization, you may wish to disable the platform’s search feature. You can do so using the Disable Search plugin.

This plugin prevents the search form appearing in most WordPress themes and disables the search sidebar widget. Note that the plugin only disables search from the front-end of your site. Back-end search features in the WordPress admin dashboard are unaffected.

Log into the WordPress admin dashboard and select Plugins > Add New from the sidebar. Search for the Disable Search plugin, then install and activate.

Plugin installation

Once activated, the plugin disables search features immediately – there are no settings to configure. If you wish to reinstate the search feature, simply deactivate the plugin.

Method 2. Disabling Manually Using Code

For this method, you will need to add the following code to your theme’s functions.php file. You can also add this to 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() {
add_action( 'widgets_init', 'remove_search_widget' );

The code will redirect all search queries, direct or indirect, to a 404 page. The search form in your WordPress theme will be hidden as well.


For further questions, or if you need help, please open a support ticket from your HostPapa Dashboard. Click here to learn how to do it.

Related Articles

Get online with our affordable web hosting

Get online with our affordable web hosting

Learn more now
HostPapa Mustache