Here are three different methods to modify the trash count, to 999 as an example:
Method #1
The views_edit-comments
filter:
add_filter( 'views_edit-comments', function( $views )
{
$trash_count = 999; // <-- Adjust this count
// Override the 'trash' link:
$views['trash'] = sprintf(
"<a href=%s>%s <span class="count">(<span class="trash-count">%d</span>)</span></a>",
esc_url( admin_url( 'edit-comments.php?comment_status=trash') ),
__( 'Trash' ),
$trash_count
);
return $views;
} );
Method #2
The comment_status_links
filter:
add_filter( 'comment_status_links', function( $status_links )
{
$trash_count = 999; // <-- Adjust this count
// Override the 'trash' link:
$status_links['trash'] = sprintf(
"<a href=%s>%s <span class="count">(<span class="trash-count">%d</span>)</span></a>",
esc_url( admin_url( 'edit-comments.php?comment_status=trash') ),
__( 'Trash' ),
$trash_count
);
return $status_links;
} );
Method #3
Here we target the edit-comments.php
screen and adjust the corresponding instance of the wp_count_comments()
function:
add_filter( 'load-edit-comments.php', function()
{
add_filter( 'wp_count_comments', function( $stats, $post_id )
{
static $instance = 0;
if( 2 === $instance++ )
{
$stats = wp_count_comments( $stats, $post_id );
// Set the trash count to 999
if ( is_object( $stats ) && property_exists( $stats, 'trash' ) )
$stats->trash = 999; // <-- Adjust this count
}
return $stats;
}, 10, 2 );
} );
Similarly for the pending and spam counts.