WordPress.org

Ready to get started?Download WordPress

Forums

how to add comment counts in mini loop on static pages (3 posts)

  1. dan_gintis
    Member
    Posted 8 years ago #

    I'm pretty new to WordPress, so this may be a very simple question...I hope it is.

    I'm in the process of creating a new web site that's centered around a WordPress blog. Aside from the blog, I have about 23 static, non WordPress pages. Every page needs to have in its sidebar a list of the five most recent posts. This I've done by changing my HTML pages to PHP, and adding the following code, lifted from a codex page:

    <?
    $news=$wpdb->get_results("SELECT
    ID,post_title FROM $wpdb->posts
    WHERE post_status= \"publish\" ORDER BY 'ID' DESC LIMIT ".$how_many);
    foreach($news as $np){
    printf ("<a href=\"..wordpressindex.php?p=%s\">%s</a><BR>", $np->ID,$np->post_title);
    }?>

    It works great, but I can't figure out how to add the comment counts to the end of each post title. I've done it on the wordpress pages with this

    <?php comments_popup_link('[0]', '[1]', '[%]'); ?>

    inside the

    <?php while (have_posts()) : the_post(); ?>

    tags. Any help will be greatly appreciated...go WordPress!

  2. swani
    Member
    Posted 7 years ago #

    Dan, I came across your post while looking for the same information. I finally got it! This is the tage you need

    <?php comments_template(); ?>

    If you want to see the discussion around it see here.

    http://wordpress.org/support/topic/68104?replies=8

    I hope that does it because I am obviously a newbie as well so I probably can't help if this isn't the answer you are looking for.

  3. dan_gintis
    Member
    Posted 7 years ago #

    Hmm, unfortunately that's not really what I'm trying to do. I'm not looking to add comment functionality to these pages, just to have a count of the comments appear next to the links I've incoluded to the five most recent posts.

Topic Closed

This topic has been closed to new replies.

About this Topic