我已经修改了@rudtek的答案,我正在这里显示代码。基本上count_user_posts 所需功能name 方法传递给post类型,否则,输出为“0”。
add_action( \'dashboard_glance_items\', \'cpad_at_glance_content_table_end\' );
function cpad_at_glance_content_table_end() {
$args = array(
    \'public\' => true,
    \'_builtin\' => false,
);
$output = \'object\';
$operator = \'and\';
$post_types = get_post_types( $args, $output, $operator );
foreach ( $post_types as $post_type ) {
    $user_ID = get_current_user_id();
    $num_posts = count_user_posts( $user_ID , $post_type->name );
    $text = _n( $post_type->labels->singular_name, $post_type->labels->name, intval( $num_posts->publish ) );
    if ( current_user_can( \'edit_posts\' ) ) {
        $output = \'<a href="edit.php?post_type=\' . $post_type->name . \'">\' . $num_posts . \' \' . $text . \'</a>\';
        echo \'<li class="post-count \' . $post_type->name . \'-count">\' . $output . \'</li>\';
        } else {
        $output = \'<span>\' . $num_posts . \' \' . $text . \'</span>\';
            echo \'<li class="post-count \' . $post_type->name . \'-count">\' . $output . \'</li>\';
        }
    }
}