How To Disable WordPress Search

Jauhari

How To Disable WordPress Search? I got the answer from WPEngineer.com, This nice tips is will disable WordPress Search more easy and of course easy to do. Why disable WordPress search? Here some of my reason. Some time WordPress based application didn’t need this featured.

disable-wordpress-search

Here we go, If you set the variable $error to true, then you will be fowarded to the error page of the theme, if not, then you will remain on the page from where the search was started.

[sourcecode language=’php’]
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;” ) );
[/sourcecode]

This is some tips that I got and you can read more details on this post.

15 thoughts on “How To Disable WordPress Search”

  1. Pingback: Green Earth Justin
  2. Pingback: ProfitsRxâ„¢
  3. halo mas jauhari.salam kenal dari saya.
    tau caranya menngeser menu page yang ada di wordpress ga ya? cos punyaku kok jadi numpuk sama serach bar ya..?
    thx mas..

    Reply

Leave a Comment

Hot Nows ionicons-v5-c