WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to show the 3 most recent comments and have a small div underneath that shows how many replies each comment has (count how many comments where comment_parent => comment_ID).

I do this by looping through each parent comment (comment_parent => 0) and then for each parent comment, use get_comments(comment_parent => $comment_ID).

Unfortunately the comment_parent is ignored on the inner-loop of each comment and I get returned an array of comments where comment_parent => 0. Why is comment_parent getting ignored?

<?php $args = array(
                    'number' => 3,
                    'status' => 'approve',
                    'comment_parent' => 0
$recent_comments = get_comments($args);
foreach($recent_comments as $recent_comment){
    echo '<div class="front-page-comments">';
    echo $recent_comment->comment_content;
    echo '</div>';
    $parent_comment_id = $recent_comment->comment_ID;
    $comment_meta_args = array(
                               'status' => 'approve',
                               'comment_parent' => intval($parent_comment_id),
                               'number' => 3
    $replies = get_comments($comment_meta_args);
    echo '<div class="front-page-comment-meta">';
    echo $parent_comment_id . '<br />';
    echo '<pre>';
    echo '</pre>';

    //echo $replies . 'Replies';
    echo '</div>';

share|improve this question
up vote 2 down vote accepted

In the wordpress codex function reference for comments, it looks like the parameter for the parent is not comment_parent but just parent. Which is weird and inconsistent because the return values are prefixed with comment_.

share|improve this answer
Thanks, I eventually noticed. – AlxVallejo Jul 20 '12 at 1:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.