How to display post count in Categories metabox in dashboard?

Dashboard -> Posts -> Add New

I would like to be able to see the number of posts in each category, withouth going to Dashboard -> Posts -> Categories.

I know it has an ID of categorydiv somewhere in the code. Maybe there is a way to change it in the code, but I am not sure where to find it.

Read More

How can I do it? Or is there a plugin?

Related posts

Leave a Reply

1 comment

  1. Hooking into the_category and taking care of only applying it in the correct screen, we can add a category count just after its name.

    <?php
    /*
        Plugin Name: Category count in Meta Box
        Version: 0.1
        Plugin URI: http://stackoverflow.com/q/13117968/1287812
        Author: Rodolfo Buaiz 
        Author URI: http://wordpress.stackexchange.com/users/12615/brasofilo
    */
    
    // The hook "load-{$pagenow}" only runs in admin and in the specified page
    add_action( 'load-post-new.php', 'add_filter_cat_so_13117968' );
    add_action( 'load-post.php', 'add_filter_cat_so_13117968' );
    
    function add_filter_cat_so_13117968()
    {
        // Run only in correct post type
        global $typenow;
        if( 'post' != $typenow )
            return;
    
        add_filter( 'the_category', 'filter_cat_so_13117968' );
    }
    
    function filter_cat_so_13117968( $cat_name )
    {
        $cat_id = get_cat_ID( $cat_name );
        $category = get_category( $cat_id );
        $count = $category->category_count;
        return "$cat_name ($count)";
    }
    

    category counter in post meta box