diff --git a/includes/wc-product-functions.php b/includes/wc-product-functions.php index 5d4479cd0e3..a8ca9dc27c2 100644 --- a/includes/wc-product-functions.php +++ b/includes/wc-product-functions.php @@ -247,8 +247,11 @@ function wc_product_post_type_link( $permalink, $post ) { $terms = get_the_terms( $post->ID, 'product_cat' ); if ( ! empty( $terms ) ) { - usort( $terms, '_usort_terms_by_ID' ); // order by ID - + if ( function_exists( 'wp_list_sort' ) ) { + $terms = wp_list_sort( $terms, 'term_id', 'ASC' ); + } else { + usort( $terms, '_usort_terms_by_ID' ); + } $category_object = apply_filters( 'wc_product_post_type_link_product_cat', $terms[0], $terms, $post ); $category_object = get_term( $category_object, 'product_cat' ); $product_cat = $category_object->slug;