I'm looking for the simplest method of preserving the term order in a non-hierarchical taxonomy on a per-post basis. I was able to achieve this previously using the following code in register_taxonomy
coupled with a get_the_terms
filter.
'sort' => true,
'args' => array( 'orderby' => 'term_order' ),
As of WordPress 4.7 this no longer seems to work, and the sort
argument no longer appears to do anything at all.
All I need is to be able to enter "bananas, apples, pears" in a "Fruits" taxonomy field on the Add/Edit Post page and have that term order preserved after I press "Publish" or "Update." The next post could list "pears, bananas, apples". Right now even if I can get that original order to stick after the initial Publish, because it alphabetizes it on the admin page any original order is lost on subsequent publishes/updates to the Post.
Is there a filter I can apply to prevent the values from being reordered alphabetically, or does the actual term order need to be saved as separate metadata?
For reference, the code I had originally used (which I've seen reused here to answer similar questions) is at the bottom of this page: https://core.trac.wordpress.org/ticket/5857 and term_order
is discussed in further detail here: https://core.trac.wordpress.org/ticket/9547