WordPress.org

Ready to get started?Download WordPress

Forums

Empty search query shows blank page (4 posts)

  1. BeautyPirate
    Member
    Posted 2 years ago #

    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')); ?>" />
    </form>

    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:

    http://www.mydomain.com/?s=Search+Site...

    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

  2. David Gard
    Member
    Posted 2 years ago #

    search.php may be the culprit here. Check the code in that file and check what happens if there is no matches.

  3. BeautyPirate
    Member
    Posted 2 years ago #

    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?

  4. David Gard
    Member
    Posted 2 years ago #

    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'] = '';
    endif;

Topic Closed

This topic has been closed to new replies.

About this Topic