• Resolved Keith

    (@sononaco)


    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)
  • Plugin Author Shamalli

    (@mihail-chepovskiy)

    What exact “select lists” do you mean? There are multiple types of categories display in the plugin: at the backend, at the frontend, on submission form, search filters lists.

Viewing 1 replies (of 1 total)
  • The topic ‘Sorting select lists?’ is closed to new replies.