• Resolved ThreeD

    (@threed)


    I have the code below. It shows random posts in the sidebar just fine and the date for each post is correct too, but all posts are listed with “1 comment”, and that’s not correct. What do I have to add to list each random post title with the correct # of comments made?

    <div class=”poposts”><span id=”heading”>Random Posts..</span>
    <?php
    $rand_posts = get_posts(‘numberposts=5&orderby=rand&cat=-43’);
    foreach( $rand_posts as $post ) :
    ?>
    <div class=”rhead”>”><?php the_title(); ?></div>
    <div class=”rdate”>Posted <?php the_time(‘F jS, Y’) ?></div>
    <div class=”rcomment”><?php comments_popup_link(‘No Comments’, ‘1 Comment’, ‘% Comments’); ?> </div>
    <?php endforeach; ?>
    </div>

Viewing 1 replies (of 1 total)
  • Thread Starter ThreeD

    (@threed)

    Nevermind, a WP guru on twitter gave me the quick fix.

    The solution is simple -> Change the <?php comments_popup_link ……?> with <?php echo $post->comment_count; ?> comments`

    That’s all 🙂

Viewing 1 replies (of 1 total)
  • The topic ‘List 5 Random posts with # of comments’ is closed to new replies.