WordPress.org

Support

Support » How-To and Troubleshooting » Counting comments of previous posts

Counting comments of previous posts

  • I’m attempting to include the title, excerpt, date, and comment count of the previous five posts. The code I’m using is:

    <div>
    <h2>...</h2>
    <?php $posts = get_posts('numberposts=5&offset=1&category=1'); foreach($posts as $post) :?>
    <div>
    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    <?php the_excerpt(); ?>
    <p class="postdate"><?php the_time('d/m/Y') ?>
    <p class="comments"><?php comments_popup_link('0 comments', '1 comment', '% comments'); ?>
    </div>
    <?php endforeach; ?>
    </div>

    Everything displays perfectly, except the comment count of the individual posts (each show zero) even though the comment link works. Any ideas on how to correct?

  • The topic ‘Counting comments of previous posts’ is closed to new replies.
Skip to toolbar