Skip to content

Instantly share code, notes, and snippets.

@berkaygeldec
Created June 18, 2019 17:24
Show Gist options
  • Select an option

  • Save berkaygeldec/bb9a800a7966e23a0a0ddfc4ab2a62df to your computer and use it in GitHub Desktop.

Select an option

Save berkaygeldec/bb9a800a7966e23a0a0ddfc4ab2a62df to your computer and use it in GitHub Desktop.
function wpb_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', 'wpb_filter_query' );
add_filter( 'get_search_form', create_function( '$a', "return null;" ) );
function remove_search_widget() {
unregister_widget('WP_Widget_Search');
}
add_action( 'widgets_init', 'remove_search_widget' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment