Popular Posts: How To List Them by Comments Count

StevenWordPress

For your fresh blog readers, it can be pretty tricky to find the most valuable posts in your archives. This is why a very interesting thing to do on your WordPress blog is to share a list of your most popular posts.

There are many plugin-based solutions to get a list of popular posts, however, you might want to keep your blog as clean as possible by using a minimum number of plugins.

The idea is to get a list of your popular posts by comment count, simply paste the following code where you want it to be displayed:

Learn how I made $33,543 online in the past 12 months.

Simply input your best email below to get started.

<?php $pop = $wpdb->get_results("SELECT id, post_title, comment_count FROM {$wpdb->prefix}posts WHERE post_type='post' ORDER BY comment_count DESC LIMIT 10"); ?>
<ul>
<?php foreach($pop as $post) : ?>
<li> <?php echo $post->post_title; ?> </li>
<?php endforeach; ?>
</ul>

Learn how I made $33,543 online in the past 12 months.

Simply input your best email below to get started.

Learn how I made $33,543 online in the past 12 months.

Simply input your best email below to get started.

No thanks, I have enough money