diff --git a/wp-includes/query.php b/wp-includes/query.php index ed08ebc450..14942d94ec 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2231,10 +2231,6 @@ class WP_Query { } } - if ( !empty( $this->tax_query->queries ) || !empty( $q['meta_key'] ) ) { - $groupby = "{$wpdb->posts}.ID"; - } - // Author/user stuff if ( empty($q['author']) || ($q['author'] == '0') ) { @@ -2480,6 +2476,10 @@ class WP_Query { $where .= $clauses['where']; } + if ( ! empty( $this->tax_query->queries ) || ! empty( $q['meta_query'] ) ) { + $groupby = "{$wpdb->posts}.ID"; + } + // Apply filters on where and join prior to paging so that any // manipulations to them are reflected in the paging by day queries. if ( !$q['suppress_filters'] ) {