How to sort terms in custom taxonomies?
-
Hello dear forum members,
hope you can help me with my problem.I work with custom taxonomies. I have successfully registered them in my functions.php and used them to assign (multiple and hierarchically structured) values to my posts.
My structure is similar to this example:
Taxonomy: Habitat
Terms:- A–America
- a–USA
- b–Canada
- c–Mexiko
- B–Europe
- a–France
- b–Spain
- c–Italy
etc.
Now I want to display them via my single.php-Template. To do so, I used
<?php the_terms( $post->ID, 'habitat', '<li> <strong>Habitat:</strong> ', ' ','</li>' ); ?>
This works, but the output is unhierarchical, in alphabetic order, and looks like this, for example:Habitat: A-America, a–France, a–USA, B–Europe, b–Spain
What I want is:
Habitat: A-America, a–USA, B–Europe, a–France, b–Spain
Is there a way to influence the sorting? Like, by ID?
Thank you very much!
The topic ‘How to sort terms in custom taxonomies?’ is closed to new replies.