how to add comment counts in mini loop on static pages
-
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:
<?
ID
$news=$wpdb->get_results("SELECT,
post_titleFROM $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!
- The topic ‘how to add comment counts in mini loop on static pages’ is closed to new replies.