This website uses cookies to allow us to see how the site is used. If you continue to use this site, we assume that you are okay with this. If you want to use the sites without cookies, please see our privacy policy.

Disable the WordPress Public Search

Sometimes you just might not need the search functionality for your website but, just by not enabling it doesn’t mean the content is not searchable, If for any reason you need to disable the WordPress public search use this function.

function my_disable_public_search( $q ) {
	if ( $q->is_admin ) {
		return $q;

	if ( $q->is_search ) {
		unset( $_GET['s'] );
		unset( $_POST['s'] );
		unset( $_REQUEST['s'] );
		$q->set( 's', '' );
		$q->is_search = false;

add_action( 'parse_query', 'my_disable_public_search', 5 );


Founder of Delicious Brains, the company behind the WP Migrate DB Pro plugin.

2 thoughts on “Disable the WordPress Public Search

  1. Awesome blog! Is your theme custom made or did you download
    it from somewhere? A design like yours with a few simple tweeks would really make my blog jump
    out. Please let me know where you got your design.
    With thanks

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.