Skip Navigation

[Résolu] Sorting taxonomy terms in filter

This support ticket is created Il y a 3 années et 11 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par marcB-6 Il y a 3 années et 11 mois.

Assisté par: Christian Cox.

Auteur
Publications
#1869893
Schermafbeelding 2020-12-09 om 11.41.47.png

Hi guys,
i try to find a way to sort the values in a filter (dropdown, see screenshot). All values come from one taxonomy. I see that i can only sort them ascending and descending. Is there any way to sort them in a custom order?
Thanks!
Marc

#1870867

It depends on the order you want to achieve. We use the get_terms API from WordPress to query terms, so it may be possible to filter get_terms using an orderby parameter:
https://developer.wordpress.org/reference/functions/get_terms/#parameters
https://developer.wordpress.org/reference/classes/wp_term_query/__construct/#parameters

However, an arbitrary sort order isn't really possible in this query because of WordPress API limitations. In that case, you can see how to set up your own arbitrary sort order manually in a wpv-control shortcode here:
https://toolset.com/forums/topic/wpv-control-need-to-customize-the-order-of-the-taxonomy-terms/

#1871461

Thanks Christian, we'll dive into it. If any questions, i'll open a new thread.
Marc