I'm attempting to display some WooCommerce attributes on a page based on their menu order using get_the_terms and cannot get it to work. Originally, I used this code and it worked fine:

$product_values = get_the_terms( $product_id, 'my_value_here');
foreach ( $product_values as $product_value ) {
    // do stuff here like echo $product_value->slug

But when I tried applying a sorting solution (such as Sorting Attributes order when using get_the_terms), it does not work. Here's another one I tried that did not work: get_the_terms in descending alphabetical order

In the WordPress Admin, I have the ability to drag-and-drop these attributes to re-sort them. How can I then display them on the site in my sorted order?

Also, to give more detail, I'm displaying the Product Variations on the page using the Attributes created in the back-end of WP. So maybe it's the variations that I need to be able to sort.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.