Skip to content

Instantly share code, notes, and snippets.

@Inzman
Created September 4, 2019 08:56
Show Gist options
  • Select an option

  • Save Inzman/d3b1126b965ecb5fe3d3fe8eba62227d to your computer and use it in GitHub Desktop.

Select an option

Save Inzman/d3b1126b965ecb5fe3d3fe8eba62227d to your computer and use it in GitHub Desktop.
Disable Wordpress search
function disable_search( $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', 'disable_search' );
add_filter( 'get_search_form', create_function( '$a', "return null;" ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment