Skip Navigation

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

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.

This topic contains 1 réponse, has 2 voix.

Last updated by Christian Cox Il y a 2 années.

Assigned support staff: 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.

Le sujet ‘[Fermé] Sort taxonomy by custom field internal to a form’ est fermé à de nouvelles réponses.