Different Ways to Display Most Commented Posts in WordPress

Different Ways to Display Most Commented Posts in WordPress

Do you wish to display your most commented posts in WordPress?

Showing your most commented posts helps your visitors find your best content, increase pageviews, and boost website engagement.

So we’ll show you step by step on how to display the most commented posts in WordPress.

What is Comment post in WordPress?

Comments allow your website’s visitors to have a discussion with you and each other. When you activate comments on a Page or post, WordPress inserts several text boxes after your content where users can submit their comments. Once you approve a comment, it appears underneath your content.

Why you need to Display the Most Commented Posts in WordPress?

Most commented posts have very high levels of user engagement. By displaying your popular posts, you encourage new readers to join the discussion and spend more time on your WordPress website, while boosting your social proof.
Which makes visitors stay on your site longer, this gives you a chance to convince them to read another post, join your Facebook page,Join your Email list or make a purchase.

let’s take a look at how to simply display your most commented posts in WordPress

How to Display Most Commented Posts in WordPress

There are different ways to Display Most commented in WordPress, but we will show you two different ways so that new visitors won’t leave without commenting, they become part of the community which will help you build trust with your readers over the long term.

Display Most Commented Posts Manually in WordPress

This method involves adding code to your WordPress files, so you must be very careful in doing this. There are two different downsides using this methods which are;
the code isn’t as optimized for performance as the MonterInsights plugin, so it will increase the server load, and it can slow down your website.
it involves adding code to WordPress, so it’s not very beginner friendly.

Doing this, you will need to add the following code to your functions.php file, in a site-specific plugin,

function wpressb_most_commented_posts() { 
// start output buffering
ob_start();
?>
<ul class="most-commented">
<?php 
// Run WP_Query
// change posts_per_page value to limit the number of posts
$query = new WP_Query('orderby=comment_count&posts_per_page=10'); 
  
//begin loop
while ($query->have_posts()) : $query->the_post(); ?>
  
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> <span class="wpressb-comment-count"><?php comments_popup_link('No Comments;', '1 Comment', '% Comments'); ?></span></li>
<?php endwhile; 
// end loop
?>
</ul>
<?php
  
// Turn off output buffering
 $output = ob_get_clean(); 
  
//Return output 
return $output; 
}
// Create shortcode
add_shortcode('wpressb_most_commented', 'wpressb_most_commented_posts'); 
  
//Enable shortcode execution in text widgets
add_filter('widget_text', 'do_shortcode');

The code above will run a database query and fetch 8-10 posts ordered by the highest comment count. Then, it uses output buffering to create a shortcode you can use to display the posts.

The last line of the code creates a shortcode that you can use in your posts, pages, and widget areas.

To display your popular posts, add this codes to your wordpress site.

[wpressb_most_commented]

If you want to add thumbnails next to your post titles, then add the following line of code right after <Li> tag in the code above.

<?php the_post_thumbnail(array(40,40)); ?>

Once you’ve done that, you can style how your most commented posts will display.

To do this you can modify the .most-commented and .wpressb-comment-count CSS classes in your WordPress theme’s stylesheet.

.most-commented li { 
border-bottom:1px solid #eee; 
padding-bottom:3px; 
} 
.most-commented li :after { 
clear:both;
} 
.most-commented img { 
padding:3px;
margin:3px;
float:left;
}
.wpressb_comment_count a, .wpressb_comment_count a:active, .wpressb_comment_count a:visited, .wpressb_comment_count a:hover { 
color:#FFF;
}
Display Most Commented Posts With a Plugin in WordPress

Different WordPress popular posts plugins that you can use to display your popular articles, but the simplest to use is MonsterInsights.

MonsterInsights which is the best Google Analytics plugin for WordPress used by over 3 million websites. It lets you properly setup Google Analytics without editing code or hiring a developer.

They have the best Popular Posts feature which allows you to show your popular articles anywhere on your WordPress site. You can use also use Inline Popular Posts to show articles inside your content.

The plugin offers different themes to choose from, and you can customize the design by changing the title color, size, label color, border, and more.

You need to do is install, activate, and set up the plugin
There is a free version of MonsterInsights, but we’re using the pro version for this tutorial since it includes the popular posts feature.

Upon activation, navigate to Insights » Popular Posts and then click the ‘Popular Posts Widget’ menu item.

Display Most Commented Posts Using MonsterInsight

There are a ton of other customization options on this screen as well. Simply select the ‘Theme’ you want to use for your most commented posts. The theme operates similar to your WordPress theme and will control the overall design of the most commented posts widget.

After that, you have more options for customizing the design. Once you’re finished customizing the appearance of your commented posts, it’s time to display your popular posts by comments.

In the ‘Sort By’ meta box, simply select the ‘Comments’ button.

sort by most commented

MonsterInsights will automatically display your most commented posts.

We hope this article helped you learn how to easily Display Most Commented Posts in WordPress. If you liked this article, then please like our page on Facebook and subscribe to our YouTube Channel for WordPress video tutorials. so we can get you more information about it.

Share this Post

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top