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);

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?

© 2021-2024 - Adminify | All rights reserved

WP Adminfy accepted payment methods