Support » Fixing WordPress » Empty search query shows blank page

  • Hey guys…

    I´m not exactly sure since when this occurs as I´ve only accidently found this out today.

    I´m on a TwentyTen Child theme and I have a searchform.php

    <form method="get" id="searchform"
        action="<?php echo get_option('home'); ?>" >
    <label class="hidden" for="s"></label>
    <input type="text" name="s" id="s"
        value="Search Site..."
        onblur="if (this.value == '')
        {this.value = 'Search Site...';}"
        onfocus="if (this.value == 'Search Site...')
        {this.value = '';}" />
    <input type="submit" id="searchsubmit"
        value="<?php echo attribute_escape(__('Search')); ?>" />

    However, if I hit the search button without entering search word I am getting a Sorry, this site is under construction page from my provider:

    Why does the search actually SEARCH for the value=”.. words and is there a way to prevent this? I would be okay if it would simply return to the main page!

    Thank you for any help

Viewing 3 replies - 1 through 3 (of 3 total)
  • search.php may be the culprit here. Check the code in that file and check what happens if there is no matches.

    Good point but I haven´t changed search.php at all.

    It might be a mistake in how I inserted the “Search Site…” value? Actually it should not search for this when submitted.

    Is there a parameter I can add to tell it if this specific query is made it should return a /?s= or a “nothing found” result?

    Maybe with filters or JS, but I’ve not explored that before. I just check when actually doing the search if $_GET['s'] === 'Search Site'

    if($_GET['s'] === 'Search Site') :
        $_GET['s'] = '';
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Empty search query shows blank page’ is closed to new replies.