WordPress being the best and most popular CMS framework and due to its flexibility to add new features using a huge library of WordPress plugins, it is now possible to create any type of websites in WordPress. Most of these WordPress plugins and even custom development use WordPress feature of custom post types.

You might want to show all custom post types used on your website to display in “At a Glance” Metabox of WordPress dashboard. To display custom post types in “At a Glance” meta box add below code in your functions.php file of your active WordPress theme.
Method 1: Simple Filter Hook
add_filter( 'dashboard_glance_items', 'add_cpt_to_glance' );
function add_cpt_to_glance( $items = array() ) {
$post_types = array( 'your_cpt_slug', 'another_cpt_slug' ); // Add your CPT slugs
foreach ( $post_types as $type ) {
if ( ! post_type_exists( $type ) ) continue;
$num_posts = wp_count_posts( $type );
if ( $num_posts ) {
$published = intval( $num_posts->publish );
$post_type = get_post_type_object( $type );
$text = _n(
'%s ' . $post_type->labels->singular_name,
'%s ' . $post_type->labels->name,
$published,
'your-textdomain'
);
$text = sprintf( $text, number_format_i18n( $published ) );
if ( current_user_can( $post_type->cap->edit_posts ) ) {
$items[] = sprintf(
'%2$s',
$type,
$text
);
} else {
$items[] = sprintf(
'%2$s',
$type,
$text
);
}
}
}
return $items;
}
Method 2: Dynamic — Auto-detect All Public CPTs
add_filter( 'dashboard_glance_items', 'add_all_cpts_to_glance' );
function add_all_cpts_to_glance( $items = array() ) {
$args = array(
'public' => true,
'_builtin' => false, // Exclude built-in post types (post, page)
);
$post_types = get_post_types( $args, 'objects' );
foreach ( $post_types as $post_type ) {
$num_posts = wp_count_posts( $post_type->name );
$published = intval( $num_posts->publish );
$text = _n(
'%s ' . $post_type->labels->singular_name,
'%s ' . $post_type->labels->name,
$published,
'your-textdomain'
);
$text = sprintf( $text, number_format_i18n( $published ) );
if ( current_user_can( $post_type->cap->edit_posts ) ) {
$items[] = sprintf(
'%2$s',
$post_type->name,
$text
);
} else {
$items[] = sprintf(
'%2$s',
$post_type->name,
$text
);
}
}
return $items;
}
