Display Comment Count
This snippet displays the total number of comments for a post, excluding pingbacks and trackbacks.
PHP
function get_comment_count($post_id) {
$comments = get_comments(array(
'post_id' => $post_id,
'status' => 'approve',
'type' => 'comment'
));
return count($comments);
}
// Usage
echo 'This post has ' . get_comment_count(get_the_ID()) . ' comments.';
Snippet Feedback
Did this snippet work for you? Do you have any questions about this snippet? Leave some feedback below.
SHARED BY
1 Views