Support » Fixing WordPress » Adding post count

  • Hi all,

    Im using this code:

    $comments = get_comments('status=approve&number=5');
      foreach($comments as $comment) :?>
      <?php $my_id = $comment->comment_post_ID ; $post_id_comms = get_post($my_id); $title = $post_id_comms->post_title;?> 
        Who: <?php echo($comment->comment_author);?><br />
        About: <a href="<?php echo get_permalink($my_id) ?>#comment-<?php echo $comment->comment_post_ID?>" title="on <?php echo $title ?>"><?php echo $title ?></a><br />
        What they said: <?php echo($comment->comment_content);?><br />
        When they said it: <?php echo($comment->comment_date);?><br />
      <?php endforeach;?>

    to output the most recent comments on a homepage but am struggling to find the correct code that also outputs the comment count for each post with a recent comment. All I have managed to do so far is zero for all comments.

    Any ideas?
    Many thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • are you using comment_number ?

    on the homepage its just the code above but on single pages each comment is assigned a number. Is that what you mean?

    Ah, sorry. Comment_number just returns 0 for everything.

    A little more info in the hope someone knows the answer.
    Im using the code in post 1 to create a page of latest comments so when a new comment is left it goes to the top (Like how a forum works) . Its all working fine but I am unable to work out how to show the amount of comments on each post next to each latest comment.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding post count’ is closed to new replies.