I use traded comments so each comments receive multiple replies in it. I need to get replies count of each individual comment. I don't need the total replies count of all the comments.
I tried to use this code:
$comment_id = get_comment_ID();
$childrenCount = get_comment_meta( $comment_id, "childrenCount" );
$childrenCountNumber = count($childrenCount);
echo $childrenCountNumber
The other way round that shows total replies which not what I'm looking for.. This code shows all the replies of all the comments.`
Code in functions.php
function replies_counter($id){
global $wpdb;
$query = "SELECT COUNT(comment_post_id) AS count FROM $wpdb->comments
WHERE `comment_approved` = 1 AND `comment_post_ID` = $id AND
`comment_parent` = 0";
$parents = $wpdb->get_row($query);
return $parents->count;
}
Then echo out in the template page:
$parents_count = replies_counter($post->ID);
$children_count = $post->comment_count - $parents_count;
echo $children_count;
This one is all about getting total replies count of all the comments. But I need replies count of each comment individually.
It will be nice if someone help me.