Forked from pradeepdotco/disable-wordpress-search.php
Last active
January 10, 2022 15:29
-
-
Save InstanceFactory/73197b69681fa727e900f4f65086bbd1 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
/* | |
* | |
* 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