Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Nothing entered in search results in display of 'home', fix presented #97

Closed
elimc opened this Issue · 1 comment

2 participants

@elimc

When someone enters nothing into the search field, the user is redirected to the 'home' page.

See issue here along with fix:

http://wordpress.org/support/topic/blank-search-sends-you-to-the-homepage

Code to add to the functions file to fix issue:

/**
 * When user enters nothing in search, my_request_filter returns list of posts
 * 
 * @link http://wordpress.org/support/topic/blank-search-sends-you-to-the-homepage
 * @param string $query_vars
 * @return string
 */
function my_request_filter( $query_vars ) {
    if( isset( $_GET['s'] ) && empty( $_GET['s'] ) ) {
        $query_vars['s'] = " ";
    }
    return $query_vars;
}
add_filter( 'request', 'my_request_filter' );

The above code will still allow the search to perform its normal duties. It only fixes things when the search form is empty.

Thoughts on this technique?

@mfields

This is what I would consider to be an issue best handled by core.

There is a ticket here: http://core.trac.wordpress.org/ticket/11330

Closing this as wontfix.

@mfields mfields closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.