Skip to content

Instantly share code, notes, and snippets.

@fastmover
Created June 23, 2015 20:59
Show Gist options
  • Select an option

  • Save fastmover/6d15299a8f6b8cc330bc to your computer and use it in GitHub Desktop.

Select an option

Save fastmover/6d15299a8f6b8cc330bc to your computer and use it in GitHub Desktop.
<?php
/**************************************************************************
Plugin Name: Disable Search Query
Description: Disables Search Queries in URL
Version: 0.0.1
Author: Fastmover
**************************************************************************/
class SK_Disable_Search_Query {
public function __construct() {
add_action( 'parse_query', array( $this, 'filterQuery' ) );
add_filter( 'get_search_form', create_function( '$a', "return null;" ) );
}
public function filterQuery( $query, $error = true )
{
if ( is_search() ) {
$query->is_search = false;
$query->query_vars['s'] = false;
$query->query['s'] = false;
///////////// Uncomment the next 2 lines to enable showing a 404 when someone tries to search
// if ( $error == true )
// $query->is_404 = true;
}
}
}
$SKDisableSearchQuery = new SK_Disable_Search_Query();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment