Last active
August 29, 2015 14:10
-
-
Save scheurta/50401e6df4d5425ef168 to your computer and use it in GitHub Desktop.
WordPress - Redirect empty searches to search page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'pre_get_posts', function( $query ){ | |
if ( isset( $_GET['s'] ) && empty( $_GET['s'] ) && $query->is_main_query() ) { | |
$query->is_search = true; | |
$query->is_home = false; | |
} | |
return $query; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment