Disable Search

Author:Scott Reilly
Version:1.7
First released:2009-06-11
Last update:2019-03-27
Compatibility:WP 4.6 – 5.1.1
Download:[ zip ]
Description:

Disable the built-in front-end search capabilities of WordPress.

Extended Description

Prevent WordPress from allowing and handling any search requests for the site. Specifically, this plugin:

  • Prevents the search form from appearing if the theme uses the standard get_search_form() function to display the search form.
  • Prevents the search form from appearing if the theme uses a searchform.php template
  • Prevents the search item from appearing in the admin tool bar when shown on the front-end.
  • Disables the search widget.
    • Removes the Search widget from the list of available widgets
    • Deactivates any search widgets currently in use in any sidebars (they are hidden, not deleted; they’ll still be in the proper locations if this plugin gets deactivated)
  • With or without the search form, the plugin prevents any direct or manual requests by visitors, via either GET or POST requests, from actually returning any search results.
  • Submitted attempts at a search will be given a 404 File Not Found response, rendered by your site’s 404.php template, if present.

The plugin only affects search on the front-end of the site. It does not disable searching in the admin section of the site.

Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage

Find out more at the plugin’s WordPress Plugin Repository page.

Installation

  1. Install via the built-in WordPress plugin installer. Or download and unzip disable-search.zip inside the plugins directory for your site (typically wp-content/plugins/)
  2. Activate the plugin through the ‘Plugins’ admin menu in WordPress

Frequently Asked Questions

Q. Will this disable the search capabilities in the admin section of the blog?
A. No.

Q. Will this prevent Google and other search engines from searching my site?
A. No. This only disables WordPress’s capabilities with regards to search.

Q. Why do I still see a search form on my site despite having activated this plugin?
A. The most likely cause for this is a theme that has the markup for the search form hardcoded into one or more of the theme’s template files (excluding searchform.php). This is generally frowned upon nowadays (the theme should be calling get_search_form() or using searchform.php to get the search form). There is no way for this plugin to prevent this hardcoded form from being displayed.
However, even if this is the case, the form won’t work (thanks to this plugin), but it will still be displayed.

Q. Is this plugin GDPR-compliant?
A. Yes. This plugin does not collect, store, or disseminate any information from any users or site visitors.

Q. Does this plugin include unit tests?
A. Yes.

Release Log

1.7 (2019-03-27)

  • New: Add CHANGELOG.md file and move all but most recent changelog entries into it
  • Change: Initialize plugin on ‘plugins_loaded’ action instead of on load
  • Change: Merge do_init() into init()
  • Unit tests:
    • Fix: Discontinue testing deprecated is_comments_popup condition
    • Fix: Use file_exists() instead of locate_template() to verify presence of file in theme (the latter is unreliable since it is based on constants)
  • Change: Note compatibility through WP 5.1+
  • Change: Add README.md link to plugin’s page in Plugin Directory
  • Change: Update copyright date (2019)
  • Change: Update License URI to be HTTPS
  • Change: Split paragraph in README.md’s “Support” section into two

1.6.1 (2018-05-19)

  • New: Add README.md
  • New: Add FAQ indicating that the plugin is GDPR-compliant
  • Unit tests:
    • Change: Make local copy of assertQueryTrue(); apparently it’s (now?) a test-specific assertion and not a globally aware assertion
    • Change: Enable and update test_no_search_form_appears_even_if_searchform_php_exists() to use TwentySeventeen theme, since it has searchform.php
    • Change: Minor whitespace tweaks to bootstrap
  • Change: Add GitHub link to readme
  • Change: Note compatibility through WP 4.9+
  • Change: Update copyright date (2018)
  • Change: Update installation instruction to prefer built-in installer over .zip file

1.6 (2017-02-21)

  • New: Disable search item from front-end admin bar
  • Change: Prevent object instantiation
    • Add private __construct()
    • Add private __wakeup()
  • Change: Update unit test bootstrap
    • Default WP_TESTS_DIR to /tmp/wordpress-tests-lib rather than erroring out if not defined via environment variable
    • Enable more error output for unit tests
  • Change: Note compatibility through WP 4.7+
  • Change: Remove support for WordPress older than 4.6 (should still work for earlier versions back to WP 3.6)
  • Change: Update copyright date (2017)
  • New: Add LICENSE file

Copyright & Disclaimer

Copyright © 2009-2019 by Scott Reilly (aka coffee2code)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Discussion / Support

Have any questions, comments, or suggestions? Please provide them via the plugin’s WordPress.org support forum. I’ll do my best to reply in a timely fashion and help as best I can.

Unfortunately, I cannot provide guaranteed support, nor do I provide support via any other means.

Was this plugin useful useful to you? Consider giving it a rating. If you’re inclined to give it a poor rating, please first post to the support forum to give me a chance to address or explain the situation.