Skip Navigation

[Resuelto] Sort taxonomy by custom field internal to a form

This support ticket is created hace 4 años, 6 meses. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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)

This topic contains 1 respuesta, has 2 mensajes.

Last updated by Christian Cox hace 4 años, 6 meses.

Assisted by: Christian Cox.

Autor
Mensajes
#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.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.