diff --git a/inc/roots-cleanup.php b/inc/roots-cleanup.php index f12a021..f9b9b34 100644 --- a/inc/roots-cleanup.php +++ b/inc/roots-cleanup.php @@ -21,6 +21,17 @@ function roots_search_query($escaped = true) { add_filter('get_search_query', 'roots_search_query'); +// fix for empty search query +// http://wordpress.org/support/topic/blank-search-sends-you-to-the-homepage#post-1772565 +function roots_request_filter($query_vars) { + if(isset($_GET['s']) && empty($_GET['s'])) { + $query_vars['s'] = " "; + } + return $query_vars; +} + +add_filter('request', 'roots_request_filter'); + // root relative URLs for everything // inspired by http://www.456bereastreet.com/archive/201010/how_to_make_wordpress_urls_root_relative/ // thanks to Scott Walkinshaw (scottwalkinshaw.com)