Skip to content

Instantly share code, notes, and snippets.

@pradeepdotco
Created November 9, 2015 22:12
Show Gist options
  • Select an option

  • Save pradeepdotco/646410736ee5f1d7c7f7 to your computer and use it in GitHub Desktop.

Select an option

Save pradeepdotco/646410736ee5f1d7c7f7 to your computer and use it in GitHub Desktop.

Revisions

  1. Pradeep Singh created this gist Nov 9, 2015.
    15 changes: 15 additions & 0 deletions disable-wordpress-search.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    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;" ) );