WordPress.org

Forums

Counting comments of previous posts (1 post)

  1. WilliamHamby
    Member
    Posted 9 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags