Disable WordPress front-end search functionality.
<?php | |
if ( ! is_admin() ) { | |
add_action( 'parse_query', function( $query ) { | |
if ( $query->is_search ) { | |
unset( $_GET['s'], $_POST['s'], $_REQUEST['s'] ); | |
$query->set( 's', '' ); | |
$query->is_search = false; | |
$query->set_404(); | |
header( $_SERVER[ 'SERVER_PROTOCOL' ] . ' 404 Not Found' ); | |
} | |
}, 5); | |
} | |
add_action( 'widgets_init', function() { | |
unregister_widget( 'WP_Widget_Search' ); | |
}, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment