Disable WordPress Search

For whatever reason the time may come when you need to disable WordPress’ in built search function, your project might not call for it or you might want to change it out for Google Search for example.

To do this is relatively easy, backup for functions.php file before you tinker, then add the following:

function no_search_please($query, $error = true) {

if (is_search()) {
$query->is_search = false;
$query->query_vars[s] = false;
$query->query[s] = false;

if ($error == true)
$query->is_404 = true;
if (!is_admin()) {
add_action('parse_query', 'no_search_please');
add_filter('get_search_form', create_function('$a', "return null;"));


And that is about it, your WordPress install now has no search function and even if someone tries to search in the address bar (eg: http://yoursite.com/?s=search-term) they will get a 404 error page.

You Might Also Like