Disable search function and redirect to home.
<?php
/**
* Disable search function and redirect to home.
*/
if (!is_admin()) {
add_filter('template_redirect', function() {
if (is_search()) {
wp_safe_redirect(home_url(), 301);
exit;
}
});
}
?>
functions.php