1

I have a Woocommerce e-shop where each product has at least five tags. The problem is each product's tags are displayed alphabetically on the single product page.

I would like to know if it's possible to display products tags without any sorting.

Supposing I entered the below tags in the following order: cTag, dTag, aTag, eTag, bTag

CURRENT display: aTag, bTag, cTag, dTag, eTag

EXPECTED display: cTag, dTag, aTag, eTag, bTag

I tried to deal with the single-product > meta.php file to manage it, but I didn't find anything to deal with the wc_get_product_tag_list function.

1
  • did you ask on woo themes?
    – rudtek
    Sep 29, 2017 at 16:38

2 Answers 2

1

wc_get_product_tag_list uses get_the_terms function, so you can use get_the_terms filter to reorder your tags:

add_filter( 'get_the_terms', 'get_the_terms_filter', 10, 3 );
function get_the_terms_filter( $terms, $post_id, $taxonomy ){
  // filter...

  return $terms;
}
1

I finally found the source of the issue:

The errors doesn't come from the display, but from the Wordpress post save/update.

How to reproduce:

  1. Go to Post/Product tags:

enter image description here

  1. Then, enter a new Tag:

enter image description here

  1. Add it to the tag list:

enter image description here

As you can see, "Kiwi" is the latest added tag, and I want to display them as is.

  1. Then save the post (product) changes:

enter image description here

As shown above, "Kiwi" isn't at the latest place anymore, it goes on the 4th place, and this isn't what I want.

To sum up, Wordpress is ordering alphabetically the different tags.

Can I tell Wordpress to let the order as the terms was entered ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.