Skip to content

Instantly share code, notes, and snippets.

@rutger1140
Created September 19, 2016 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rutger1140/7d36bf0615c38504cdd68cff5cd08f06 to your computer and use it in GitHub Desktop.
Save rutger1140/7d36bf0615c38504cdd68cff5cd08f06 to your computer and use it in GitHub Desktop.
WordPress disable search
<?php
// Add to your functions.php file
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