diff --git a/src/RestApi/Controllers/ProductReviews.php b/src/RestApi/Controllers/ProductReviews.php index 98bebeb23eb..6a9fb117439 100644 --- a/src/RestApi/Controllers/ProductReviews.php +++ b/src/RestApi/Controllers/ProductReviews.php @@ -122,7 +122,17 @@ public function get_items( $request ) { if ( isset( $registered['orderby'] ) ) { if ( 'rating' === $request['orderby'] ) { - $prepared_args['meta_key'] = 'rating'; // phpcs:ignore + $prepared_args['meta_query'] = array( // phpcs:ignore + 'relation' => 'OR', + array( + 'key' => 'rating', + 'compare' => 'EXISTS', + ), + array( + 'key' => 'rating', + 'compare' => 'NOT EXISTS', + ), + ); } $prepared_args['orderby'] = $this->normalize_query_param( $request['orderby'] ); }