Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

The order of categories on dashboard is alphabetical. Can I change it to custom order?

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
    
Thank you very much! [in addition to those plugins, I also wrote a short code that performs categories in tree veiw] –  s976 May 25 '12 at 7:25
    
I wonder, how can I show a particular term on the top? –  s976 May 25 '12 at 8:06
    
Maybe, the easiest way would be jQuery DOM manipulation, check this answer for inspiration :) –  brasofilo May 25 '12 at 8:20
    
@s976 - forgot to tag you in my previous comment... scribu's plugin, CCT, has some jQuery to auto-scroll the list, you can get some ideas from there too. –  brasofilo May 25 '12 at 9:42
    
Thank you very very much! –  s976 May 27 '12 at 19:31
add comment

There's no default option for it, but there's two other ways.

  1. Change it in the theme files http://codex.wordpress.org/Template_Tags/wp_list_categories
  2. Use a plugin. Eg http://wordpress.org/extend/plugins/my-category-order/
share|improve this answer
    
I think that you sugestion is for users side. And I am looking for how to change the order on a admin side. –  s976 May 24 '12 at 10:52
    
Both of those suggestions are for admins. Users really shouldn't have any access to the theme files, and if you look at the instructions for the plugin, it's clearly talking about admin use. –  user1337 May 24 '12 at 15:26
    
@user1337 - you are confusing the user "admin" (or having administrative powers over a site) with WordPress backend, also referred as Admin or Dashboard. –  brasofilo May 24 '12 at 19:30
    
@brasofilo - Not at all. Either the user "admin" or someone who has plugin access to the admin or dashboard can install that plugin and change the order that categories are listed in. One can also use a roles plugin to delegate that ability to other roles beside the administrator. –  user1337 May 24 '12 at 19:57
    
Will the plugin work in this meta box? –  brasofilo May 24 '12 at 20:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.