Add Custom Post Type Totals to the “Right Now” Box

There’s a pretty convenient “at a glance” widget in the Dashboard called Right Now. But if you’re using any custom post types, you may have noticed they won’t show up there.

Naturally, we can fix that:

add_action( 'right_now_content_table_end', 'post_type_totals_rightnow' );
function post_type_totals_rightnow() {    
    $post_types = get_post_types( array( '_builtin' => false ), 'objects' ); 
    if (count($post_types) > 0)
    foreach( $post_types as $pt => $args ) {
        $url = 'edit.php?post_type='.$pt;
        echo '<tr><td class="b"><a href="'. $url .'">'. wp_count_posts( $pt )->publish .'</a></td><td class="t"><a href="'. $url .'">'. $args->labels->name .'</a></td></tr>';
    }
}