Highlighting the most popular posts on your site is a great way to send new visitors to your very best content and win them over.
There are a few different ways you can do this, and quite a few plugins out there to help. But why not base it on the number of comments? If you write a post that makes people talk, it must be a well written post (Most of the time…).
<h2>Popular Posts</h2>
<ul>
<?<a title="See also WordPress - Batch Delete Post Revisions" href="http://www.whileifblog.com/2010/09/22/wordpress-batch-delete-post-revisions/">php</a> $result = $wpdb->get_results("SELECT comment_count,ID,post_title
FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5");
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>
<li><a href="<?<a title="See also WordPress - How to Display any External RSS Feed on Your Site" href="http://www.whileifblog.com/2010/12/30/wordpress-how-to-display-any-external-rss-feed-on-your-site/">php</a> echo get_permalink($postid); ?>" title="<?<a title="See also WordPress - Display post thumbnail in your RSS feed" href="http://www.whileifblog.com/2010/12/27/wordpress-display-post-thumbnail-in-your-rss-feed-2/">php</a> echo
$title ?>">
<?<a title="See also WordPress - Dynamic Copyright Date in Footer" href="http://www.whileifblog.com/2012/03/11/wordpress-dynamic-copyright-date-in-footer/">php</a> echo $title ?></a> {<?<a title="See also WordPress - Programmatically Creating Posts" href="http://www.whileifblog.com/2010/09/20/wordpress-programmatically-creating-posts/">php</a> echo $commentcount ?>}</li>
<?<a title="See also WordPress - Read More link jumps to top of post page" href="http://www.whileifblog.com/2010/12/29/wordpress-read-more-link-jumps-to-top-of-post-page/">php</a> } } ?>
</ul>

2 Comments.