Steps
-
Add the PHP code to your child theme’s
functions.phpfile or the Code Snippets plugin. -
Save and activate the snippet.
-
Go to WordPress Admin → Posts → All Posts.
Hook Used
-
manage_posts_columns— Adds the Comment Count column. -
manage_posts_custom_column— Displays the comment count for each post.
Type: WordPress Admin Customization
Output: A Comment Count column appears in the posts list, showing the number of comments associated with each post.
Why use this snippet? It helps you quickly identify posts that receive more discussion and engagement.
function custom_add_comment_count_column( $columns ) {
$columns['comment_count'] = 'Comment Count';
return $columns;
}
add_filter( 'manage_posts_columns', 'custom_add_comment_count_column' );
function custom_display_comment_count_column( $column, $post_id ) {
if ( 'comment_count' === $column ) {
echo esc_html( (string) get_comments_number( $post_id ) );
}
}
add_action( 'manage_posts_custom_column', 'custom_display_comment_count_column', 10, 2 );
Tested on
Reported by the author on October 24, 2026. WPFolks has not verified this.
Not tested against WordPress 7.1.4. It may still work.
