I have a lot of custom post types and I have them showing in my "Right Now" Dashboard but it's gotten pretty long so I want to separate them to a custom widget within the dash.
See example below:
So my question is how do I add the CPTs to a custom dashboard widget?
Any help would be awesome.
Thanks!
EDIT: This is what I have (What am I missing?)
// wp_dashboard_setup is the action hook
add_action('wp_dashboard_setup', 'mycustom_moviestats');
// add dashboard widget
function mycustom_moviestats() {
wp_add_dashboard_widget('custom_movie_widget', 'Movie Stats', 'custom_dashboard_movie_list');
}
function custom_dashboard_movie_list(){
// here is the code to add custom post types + count see below
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='edit.php?post_type=widget'>$num</a>";
$text = "<a href='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' );
}