• This also affects earlier versions. If I try and search a wordpress Blog, but forget to enter any terms I end up… on the home page. Surely on a Search, even if blank, I should be redirected to the search results page?

    I’ve just sent someone this code (not sure if it’s fully correct) as a suggested interim fix:

    function blank_search($query){
    	global $wp_query;
    	if (isset($_GET['s']) && $_GET['s']==''){
    		$wp_query->set('s',' ');
    		$wp_query->is_search=true;
    	}
    	return $query;
    }
    add_action('pre_get_posts','blank_search');

    Is this even possible to correct for a future release?

Viewing 7 replies - 1 through 7 (of 7 total)
  • In the 2.7 beta default theme after a no results search it redirects to a page saying

    “No posts found. Try a different search?”

    and listing your criteria.

    So I’d say it is fixed for 2.7.

    Thread Starter elfin

    (@elfin)

    That’s strange because in my copy it doesn’t! But I’m testing locally and occasionally that doesn’t always return the same results.

    Can someone else confirm/deny the result of submitting a blank search.

    My mistake – I thought you meant “a search that returned no results” rather than “a search for nothing”.

    If you just press enter in the search box it does indeed refresh to home.

    Thread Starter elfin

    (@elfin)

    well at least its not just me!

    You should make a plugin Rich 😉

    Thread Starter elfin

    (@elfin)

    well turning that into a plugin is ok, but it isn’t an elegant solution. I’m forcing the search into searching for a single blank space. This doesn’t allow us as developers to grab the fact that no search terms were entered. So I’d have to extend things a little bit to make it a bit more practical.

    Thread Starter elfin

    (@elfin)

    currently testing a better fix for this over on permanent tangent.

    However it requires an addition to your themes search.php so I still couldn’t solve it as a pure plugin.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Search results – or not’ is closed to new replies.