Adding Custom Post Type Counts to the Dashboard

The dashboard conveniently tells me how many posts, pages, and comments I have. I would like it to tell me how many articles, videos and cartoons I have too (three custom post types registered with my theme). How would I go about including these into the “Right Now” panel on the dashboard?

alt text

4 s
4

Yes, there are several actions within that widget, including right_now_content_table_end. Example:

function my_right_now() {
    $num_widgets = wp_count_posts( 'widget' );

    $num = number_format_i18n( $num_widgets->publish );
    $text = _n( 'Widget', 'Widgets', $num_widgets->publish );
    if ( current_user_can( 'edit_pages' ) ) { 
        $num = "<a href="https://wordpress.stackexchange.com/questions/5318/edit.php?post_type=widget">$num</a>";
        $text = "<a href="https://wordpress.stackexchange.com/questions/5318/edit.php?post_type=widget">$text</a>";
    }   

    echo '<tr>';
    echo '<td class="first b b_pages">' . $num . '</td>';
    echo '<td class="t pages">' . $text . '</td>';
    echo '</tr>';
}
add_action( 'right_now_content_table_end', 'my_right_now' );

Leave a Comment