Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Commit 47762cd

Browse files
committed
API Sites: Properly handle empty searches
Fixes jquerygh-337
1 parent 6b5eaef commit 47762cd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mu-plugins/api-sites/search-weights.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
*/
77

88
add_filter( 'the_posts', function( $posts, $query ) {
9-
if ( ! $query->is_main_query() || ! $query->is_search() )
9+
if ( ! $query->is_main_query() || ! $query->is_search() ||
10+
is_null( $query->query_vars[ 'search_term' ] ) ) {
1011
return $posts;
12+
}
1113

1214
$priorities = array_fill( 0, 4, array() );
1315

0 commit comments

Comments
 (0)