Sorting select lists?
-
Is it possible to sort select lists? I have tried hacking the get_categories() call when loading $terms by adding “orderby” => “name” and “order” => “ASC” but it doesn’t seem to work. The only workaround I have found is to create a function and run the $terms through it before they are displayed:
function w2dc_wmd_order_terms( $terms ) { ? ? ? ? $terms_order = []; ? ? ? ? foreach( $terms as $t ) ? ? ? ? { ?? ? ? ? $terms_order[ $t->slug ] = $t; ? ? ? ? } ? ? ? ? ksort( $terms_order ); ? ? ? ? $terms = []; ? ? ? ? foreach( $terms_order as $term => $t ) ? ? ? ? { ? ? ? ? ? $terms[] = $t; ? ? ? ? } ? ? ? ? return $terms; }
Of course this will get overwritten each time the plugin is updated. Can you please add a hook or filter to those terms before they are displayed?
Thank you!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Sorting select lists?’ is closed to new replies.