Skip Navigation

[Résolu] Sort taxonomy by custom field internal to a form

This support ticket is created Il y a 4 années et 7 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 1 réponse, a 2 voix.

Dernière mise à jour par Christian Cox Il y a 4 années et 7 mois.

Assisté par: Christian Cox.

Auteur
Publications
#1360641

I have a form called "Activity". The form has a taxonomy "Days of the Week", with elements Monday, Tuesday, etc. The "add Activity" form displays the Days of the Week in alphabetical order (Friday, Monday, Saturday, etc.). I can add "1 Sunday", "2 Monday", but that clutters up the selection, especially since it's also a query field for a different
view.

I added a "sort order" custom field to the taxonomy, but it's not selectable when adding the taxonomy field to the form, so it's not usable for this purpose. I don't see any way to include a query over taxonomy and add that to the form either.

What is the link to your site? Behind a firewall.

#1360893

Hi, there's no built-in way to assign an arbitrary order to these field options, unfortunately. One way you could achieve this sorting is to create a generic field and populate the options for each term manually. Since there are only 7 options to consider, this shouldn't be too difficult to maintain. Use the cred_save_data hook to capture the User's selection and add the appropriate term or terms to the post after the form is submitted.

https://toolset.com/documentation/user-guides/inserting-generic-fields-into-forms/
https://toolset.com/documentation/programmer-reference/cred-api/
https://codex.wordpress.org/Function_Reference/wp_set_object_terms

Let me know if you have questions about using Toolset's APIs and I'll be glad to offer guidance.

Ce ticket est maintenant fermé. Si vous êtes un client de Toolset et que vous avez besoin d'aide, veuillez ouvrir un nouveau ticket d'assistance