Custom Fields
Support General Prevent terms order being overwritten when updating post Reply To: Prevent terms order being overwritten when updating post


Anh Tran


Can you please tell me how do you set term order for a post?

When I go to WP database, I see the term_order is available only for term_relationships table, which stores the connections between posts and terms. And the sooner a term in inserted, the lower order it has.

When we update a post, Meta Box runs wp_set_object_terms() function to update post terms. This function does these things:

  • Insert new terms relationships for the post
  • Delete old terms relationships
  • Reset the relationships order (term_order)

The last step causes the problem you have met. You can check the source code of wp_set_object_terms() function to see more details. Here is the screenshot of that part:

View post on

The bad thing is this is the only function we can use to set post terms :(.

Maybe there’s another approach to set the order? Have you tried taxonomy_advanced field?