From 3513f50e55a894cce58c51b6c579f0ffda8f28de Mon Sep 17 00:00:00 2001 From: Justin Shreve Date: Tue, 3 Jan 2017 10:43:48 -0800 Subject: [PATCH] Add tm.meta_value to the DISTINCT list since it is being used in the ORDER BY clause. --- includes/wc-term-functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/wc-term-functions.php b/includes/wc-term-functions.php index 24ae3cf3b02..47b55087d75 100644 --- a/includes/wc-term-functions.php +++ b/includes/wc-term-functions.php @@ -483,7 +483,7 @@ function wc_terms_clauses( $clauses, $taxonomies, $args ) { return $clauses; } - // Wordpress should give us the taxonomies asked when calling the get_terms function. Only apply to categories and pa_ attributes. + // WordPress should give us the taxonomies asked when calling the get_terms function. Only apply to categories and pa_ attributes. $found = false; foreach ( (array) $taxonomies as $taxonomy ) { if ( taxonomy_is_product_attribute( $taxonomy ) || in_array( $taxonomy, apply_filters( 'woocommerce_sortable_taxonomies', array( 'product_cat' ) ) ) ) { @@ -503,7 +503,7 @@ function wc_terms_clauses( $clauses, $taxonomies, $args ) { } // Query fields. - $clauses['fields'] = 'DISTINCT ' . $clauses['fields']; + $clauses['fields'] = 'DISTINCT ' . $clauses['fields'] . ', tm.meta_value'; // Query join. if ( get_option( 'db_version' ) < 34370 ) {