Deactivating the WordPress Search Feature

<?php function ah_filter_query( $query, $error = true ) { if ( is_search() ) { $query->is_search = false; $query->query_vars[s] = false; $query->query[s] = false; // to error if ( $error == true ) $query->is_404 = true; } } add_action( 'parse_query', 'ah_filter_query' ); add_filter( 'get_search_form', create_function( '$a', "return null;" ) );
This code does deactivate the search feature entirely.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.