Comment count doesn’t seem to be correct

8.25K viewsIssuesbug
0

Hi Rahul,

I followed the WordPress Codex for number of comments per question as below

https://codex.wordpress.org/Function_Reference/comments_number

However, this doesn’t seem to report the correct number. For example, I have over 15 comments on a particular question, but the codex function returns only two ?

Doesn’t seem to matter if this is inside the loop or out.

Any thoughts ?

1

Validated as working

$args = array(
‘count’ => true,
‘parent’ => get_the_ID()
);
$totalcomments = get_comments($args);

<!– Comment Count –>
<a class=”ap-questions-count ap-questions-ccount” href=”<?php echo ap_answers_link(); ?>”>
<span itemprop=”commentCount”><?php echo $totalcomments ?></span>
<?php _e( ‘Comments’, ‘anspress-question-answer’ ); ?>
</a>

Works as intended once the comment_parent mapping is correctly configured

commented on answer

Hello Mark,
I don’t think this snnipet is doing what you are trying to achive. parent argument is used to get child comments of a comment.

You are viewing 1 out of 5 answers, click here to view all answers.