Created
November 9, 2015 22:12
-
-
Save pradeepdotco/646410736ee5f1d7c7f7 to your computer and use it in GitHub Desktop.
Disable WordPress Search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fb_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', 'fb_filter_query' ); | |
add_filter( 'get_search_form', create_function( '$a', "return null;" ) ); |
... @InstanceFactory When i used your code above, and i type in my url www.blah.com/?s=test, i get a message on my page that says: "The page can’t be found. It looks like nothing was found at this location.". I need to use the ?s= parameter as a regular parameter, not a search. How can this be done? Thanks.
@adrearubin Well, I'm not that deep within WP. But I think you need to use a 'free' parameter, means, one that is not used by WP.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
create_function is depricated. and also query[s] is depricated.
How I solved this: