The code snippet will disable the search functionality on a WordPress site. When someone tries to use the search feature in the search bar, the code stops the search from being processed. It does this by setting the search query to false so that WordPress doesn’t look for any results.
function ts_filter_query( $query ) { if ( is_search() ) { $query->is_search = false; $query->query_vars['s'] = false; $query->query['s'] = false; // Do not set 404, just return the same page $query->is_404 = false; } } add_action( 'parse_query', 'ts_filter_query' ); add_filter( 'get_search_form', function() { return null; // Disable the search form display });