Hack: Remove Search From Your Site

Not every WordPress site needs to have a search function. There are certainly lots of single-page sites out there, or those with just a few pages, and the search function just isn’t needed. Or, perhaps you have a special search page and you simply want to disable WordPress’ native search.

The first thing you may want to do is to simply remove the search widget from your theme. You can do this with a quick bit of code in your functions.php.

add_action('widgets_init', 'wpaction_remove_search_widget');
function wpaction_remove_search_widget() {

This may be all you need. But some themes code the search right into the sidebar or header, so you may also need this. Or, you could just edit the theme/child theme to get rid of that.

add_filter('get_search_form', 'wpfilter_remove_search_form');
function wpfilter_remove_search_form() {
	return null;

Finally, if you really want to make sure no one can search, you can also deny any search requests. So someone trying to make their own search query as a URL, or using a search box you forgot to get rid of, will get an error instead.

add_action('parse_query', 'wpaction_deny_search');
function wpaction_deny_search($query) {
	if (is_search()) {
		wp_die("Searching Has Been Disabled.");

Leave a Reply

Your email address will not be published. Required fields are marked *