Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save InstanceFactory/73197b69681fa727e900f4f65086bbd1 to your computer and use it in GitHub Desktop.
Save InstanceFactory/73197b69681fa727e900f4f65086bbd1 to your computer and use it in GitHub Desktop.
Disable WordPress Search
/*
*
* Start of disabling Search Functionality, in case the request blocker is not active
*
* see also: https://instance-factory.com/?p=1706#disableSearch
*/
function ifb_filter_query($query)
{
if (is_search()) {
$query->is_search = false;
$query->query_vars['s'] = false;
$query->query['s'] = false;
}
}
add_action('parse_query', 'ifb_filter_query', 1, 1);
add_filter('get_search_form', function ($a) {
return '';
});
function ifb_remove_search_widget()
{
unregister_widget('WP_Widget_Search');
}
add_action('widgets_init', 'ifb_remove_search_widget');
/*
* End of disabling Search Functionality
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment