Spooky
Halloween Sale

25%
OFF

Coupon Code:
SPOOKY25

Hour
Min
Sec
Expired

Limited Time Only

Coupon: BFCM50

⚡FLASH SALE⚡

End's Tonight

Coupon: FLASH4YOU

LIMITED TIME ONLY

Limited License Available

Day
Hour
Min
Sec
Expired

Disable WordPress Search Page & Redirect to Homeapge

WordPress has a default entier site search system. We use a search widget inside sidebar or header. If you do not use the search on your site you can disable the search results page.

You can block this search page by using the following snippet. Just copy the code and paste it inside your function.php file. 

				
					// Remove search page
add_action('template_redirect', 'jltwp_adminify_remove_archives_search');
function jltwp_adminify_remove_archives_search()
{
    if (is_search()){
        $target = get_option('siteurl');
        $status = '301';
        wp_redirect($target, 301);
        die();        
    }
}
				
			

There is another solution if you are WP Adminify user. No need to search your function.php file and paste the code. Just navigate to WP Adminify > Tweaks > Post / Archives. You will see an option named “Disable Search”, just enable it and save your settings.

disable search in WordPress website
August 29, 2021
Post and Archives
Was this article helpful?

SALE ENDS IN:

Minutes :
Seconds

— Limited Time Flash Sale—

⚡ 50% OFF ⚡

COUPON CODE: BFCM50