How to Change the Categories Order in the Admin Dashboard?

Found an answer in this answer.

add_filter( 'get_terms_args', 'wpse_53094_sort_get_terms_args', 10, 2 );
function wpse_53094_sort_get_terms_args( $args, $taxonomies ) 
{
    global $pagenow;
    if( !is_admin() || ('post.php' != $pagenow && 'post-new.php' != $pagenow) ) 
        return $args;
    
    $args['orderby'] = 'slug';
    $args['order'] = 'DESC';

    return $args;
}

The order may be ASC or DESC, and the orderby can be:

  • count
  • description (it should, but didn’t work so well for me, futher tests necessary)
  • name
  • slug


Plugins of interest

(may we call those Plinterests?)

The first two are very short and and can be easily incorporated into your code.

  • Category Checklist Expander : expands the height of the category list, so no scrolling is needed

  • Category Checklist Tree : this one rebuilds the Category Meta Box, so you can modify its code for further styling/adapting the box – and here’s a screenshot of what it does

    enter image description here

  • Gecka Terms Ordering : creates an auxiliary table in the database (wp_termmeta) to deal with the ordering. Has drag and drop capabilities.

Leave a Comment