Being trying to figure out a way to tweak the below code to go in our functions.php file, since create_function is depreciated, so that the search feature on Wordpress is disabled, and returns a 404 error, if someone goes to the search page url.
function disable_search( $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', 'disable_search' );
add_filter( 'get_search_form', create_function( '$a', "return null;" ) );
function remove_search_widget() {
unregister_widget('WP_Widget_Search');
add_action( 'widgets_init', 'remove_search_widget' );
As still fairly new to php, not sure how to tweak the above code to work on php 8, and to stop the search feature being used in Wordpress.