Tell us what you are trying to do?
In one of our CRED post forms, we are displaying the values of a taxonomy, but there doesn't appear to be a neat way of displaying the items from the taxonomy in a sensible manner, other than the default alphabetical sort.
Eg we have a taxonomy AVAILABLE DAYS which I would like to display in the logical order for days of the week, ie Monday, Tuesday, ... , Sunday. I could achieve this easily if I could sort by slug.
I've also seen a few posts on this in your support forum, but they are several years old and I wondered had this feature been improved and perhaps remained undocumented?
Do you know of a non-complicated way to display the taxonomy terms sorted by slug asc? Or is there an easy workaround?
There are no options for modifying the ordering settings for the taxonomy terms.
Overriding the existing order would ordinarily require custom code.
I was just looking into an example using pre_get_terms and I thought it would be nicer rather than you having to tweak the term stubs to get the right order to use a plugin that offers you a drag and drop interface to set your order, and to then use a code snippet to make sure the form uses that custom order when outputting the terms.
But when I set up a quick test with my preferred plugin for this, I found the custom code wasn't required, the form displayed the terms in the manual order anyway.
Thanks for that. I have spotted a few other plugins with similar functionality. I will need to try them all out and see how they behave with translations. Eg Monday to Sunday might work in English but it would not work in Spanish... Also I noticed that the default alphabetical order has gone now too in English for all other taxonomies we had that were just displayed in alphabetical order (which made sense for the front end user), so this is another one I'll need to test in another language too...
Wouldn't it be an idea to develop a orderby argument for the cred_field taking parameter (name, id, slug, date) and a sort argument taking (asc, desc)? This seems so fundamental to me, I'm surprised it hasn't been requested by everyone else yet and developed by Toolset. Feature request?
I guess this might need to be a joint effort between Toolset and WPML due to the translations?
I forgot to mention: when I activated the plugin, it gave me a message, which appeared once and then was never to be seen again.
[Unknown column 'tt.order' in 'order clause']
SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id LEFT JOIN wp_icl_translations icl_t ON icl_t.element_id = tt.term_taxonomy_id AND icl_t.element_type IN ('tax_slide-page') WHERE tt.taxonomy IN ('slide-page') AND ( ( icl_t.element_type IN ('tax_slide-page') AND ( icl_t.language_code = 'en' OR 0 ) ) OR icl_t.element_type NOT IN ('tax_slide-page') OR icl_t.element_type IS NULL ) ORDER BY tt.order ASC
I cannot say whether it can be ignored now or whether there will be an underlying problem which will raise its ugly head later. The plugin is quite old and untested on our version. The newer plugins may prove more valuable.
I'm not sure how this would interact with WPML, I guess that would require some testing.
I suggested that plugin even though it is aging because it's by a core contributor and does one simple thing, but I'm not sure what to expect when you throw WPML into the mix.
And please, by all means submit a request for more control over front-end taxonomy filters (Views filter controls and Toolset Forms), including modifying which terms are included, as well as ordering options for the terms. Filing such a request helps our product manager gauge demand when it comes to development priorities.
I'm not a PHP developer (yet! 😅) so I wouldn't know where to start with pre_get_terms.
I tried out several plugins with varying results. The one you recommend seems to do the job fine, despite throwing that message at the beginning on first activation. It's simple and intuitive to use and also allows different orders in the different languages with WPML, so just what I was looking for. I just hope it doesn't break at some point in the future! 😁
I'd be more than happy to write a feature request for CRED forms.