Skip Navigation

[Resolved] Alphabetic sort of taxonomy terms and capital letters

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by Thomas AMX 6 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#895012

Hi guys,

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?

Best regards,
Tom

#895136

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

Please check following link that may help you:
=> https://wordpress.stackexchange.com/a/21147

#900187

Hello Minesh,

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.

So, the case is resolved.

Thanks
Tom