apply_filters( ‘dashboard_glance_items’, string[] $items )

Filters the array of extra elements to list in the ‘At a Glance’ dashboard widget.

Description

Prior to 3.8.0, the widget was named ‘Right Now’. Each element is wrapped in list-item tags on output.

Parameters

$itemsstring[]
Array of extra ‘At a Glance’ widget items.

Source

$elements = apply_filters( 'dashboard_glance_items', array() );

Changelog

VersionDescription
3.8.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Add Custom Post Type to ‘At a Glance’ dashboard widget:

    function wpdocs_add_custom_post_counts() {
    	$post_types = array( 'wpdocs-project' );
    
    	foreach ( $post_types as $cpt ) {
    		$cpt_info = get_post_type_object( $cpt );
    		$num_posts = wp_count_posts( $cpt );
    		$num = number_format_i18n( $num_posts->publish );
    		$text = _n( $cpt_info->labels->singular_name, $cpt_info->labels->name, intval( $num_posts->publish ) );
    
    		echo '<li class="page-count '. esc_attr( $cpt_info->name ) . '-count"><a href="edit.php?post_type=' . esc_attr( $cpt ) . '">' . $num . ' ' . $text . '</a></li>';
    	}
    }
    add_action( 'dashboard_glance_items', 'wpdocs_add_custom_post_counts' );

    The Custom Post Type is shown with the same style as default Posts, Pages and Comments use, including number of posts and link to CPT list.

You must log in before being able to contribute a note or feedback.