I have added custom taxonomy terms to a CPT content template. The order should be ascending.
It "almost" works: taxonomy terms which are proper nouns and start with a capital letter appear first. After that, all terms starting with a lowercase letter are listed alphabetically. Capitalization affects sorting.
So, it's more or less like this:
Japan, Norway, Switzerland, beer, city, wine
At least there is a pattern 🙂 nevertheless, I would like it to behave like this:
beer, city, Japan, Norway, Switzerland, wine.
The taxonomy is 'hierarchical', but all terms are on the same level. No parent/child terms (I know this affects sorting). I made it hierarchical only to have checkboxes in the post-edit screen.
How can I fix it? Is there some function or filter?
Hello. Thank you for contacting the Toolset support.
Well - the sort order is working as expected but to get the results as per your requirement, you need to write custom shortcode where you should fetch all the taxonomy terms and convert its first letter to uppercase and then sort it.
Thank you for your response. As far as I can understand from your link, that would capitalize all terms, so they would appear as:
Beer, Japan, Norway, Wine etc.
If that is the case, I could achieve the same by manually capitalizing all tax. terms. However, I would like to capitalize only proper nouns. Like this:
beer, Japan, Norway, wine.
Essentially, what I wanted was sorting by term slug, if sorting by term name doesn't follow the alphabet. I wish sorting by term-slug was available in Fields and Views GUI.
I tried to build a shortcode using wp_get_post_terms and sort them by slug, but it broke the site.
Then I figured out, I could create a Taxonomy View and sort them by slug in the view. I inserted the view into template and it works nicely.