Custom sort order
I’d like to be able to specify a custom order for my CPT-onomies
As a simple example, if I created a CPT-onomy for days of the week, I’d like to be able to order them Sunday, Monday Tuesday, etc… (as opposed to date or name order).
I’m currently getting my terms like so:
$days = wp_get_object_terms($post->ID, 'days', array("fields" => "all"));
The entry for wp_get_object_terms() suggests that
term_ordercan be supplied as a sort field. There is a
term_orderfield in the
wp_termstable, which presumably I could hook into and set my custom order using a plugin. I could then call
$days = wp_get_object_terms($post->ID, 'days', array("fields" => "all", "orderby"=>"term_order", "order"=>"ASC"));
However, because the taxonomies created by CPT-onomies seem to be created on-the-fly (i.e. aren’t stored in the
wp_termstable), this method won’t work. Does anyone have any suggestions as to how I could make this happen?
- The topic ‘Custom sort order’ is closed to new replies.