One of the many built-in features included with WordPress is Search. As its name suggests, it allows you to search your WordPress website’s content. Nevertheless, if you want to disable this feature, you can do so with a small code snippet.
Please copy the following code and paste it into the functions.php file in the root subdirectory of your active theme.
function csc_disable_filter_query( $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', 'csc_disable_filter_query' ); add_filter( 'get_search_form', create_function( '$a', "return null;" ) );
The preceding code fragment will redirect any user search query to a 404 page. You can also insert the following code into your functions.php file to disable the Search widget on your WordPress site. function csc_disable_search_widget() { unregister_widget('WP_Widget_Search'); } add_action( 'widgets_init', 'csc_disable_search_widget' );
You Have a Special Offer! Europe’s Best WordPress 6.2 Hosting
The reputation of HostForLIFEASP.NET in the community is outstanding. Most HostForLIFEASP.NET customers are pretty pleased with this web host, based on an analysis of the feedback we have received to date. Surprisingly, even though they have received numerous reviews from actual consumers, 98.0% of them are delighted with the overall service they have received and there are almost no complaints. HostForLIFEASP.NET’s shared hosting plan includes a variety of ASP.NET hosting options. The cheapest HostForLIFEASP.NET plan, the Classic plan, costs €2.97 per month. To eradicate purchasing risks, a 30-day money-back guarantee is offered.