[wp-trac] [WordPress Trac] #11330: Empty search takes you to hompage instead of empty search page
WordPress Trac
wp-trac at lists.automattic.com
Thu Aug 23 15:31:44 UTC 2012
#11330: Empty search takes you to hompage instead of empty search page
--------------------------+-----------------------------
Reporter: jacobfogg | Owner:
Type: defect (bug) | Status: new
Priority: low | Milestone: Future Release
Component: Query | Version: 2.8.5
Severity: minor | Resolution:
Keywords: needs-patch |
--------------------------+-----------------------------
Comment (by foxinni):
This issue has come up in my development cycle too.
I'm opting for [http://core.trac.wordpress.org/ticket/11330#comment:7
strop]'s solution but I've modified it to work for me, especially the need
to put `is_home` to `false`.
{{{
function search_query_filter($query) {
// If 's' request variable is set but empty
if (isset($_GET['s']) && empty($_GET['s']) && $query->is_main_query()){
$query->is_search = true;
$query->is_home = false;
}
return $query;
}
add_filter('pre_get_posts', 'search_query_filter');
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/11330#comment:12>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list