Do you need to show your most commented posts in WordPress?
Highlighting your most commented posts helps your guests discover your greatest content material, improve pageviews, and enhance web site engagement.
On this article, we’ll present you the best way to show probably the most commented posts in WordPress, step-by-step.
Why Show the Most Commented Posts in WordPress?
Your most commented posts have very excessive ranges of consumer engagement. By displaying your widespread posts, you encourage new readers to affix the dialogue and spend extra time in your WordPress web site.
All of this collectively is an enormous enhance of social proof to your website.
When your guests keep in your website longer, you may persuade them to learn one other put up, be a part of your e-mail listing, or make a purchase order.
Plus, when new guests depart a remark, they grow to be a part of the group. This may also help you construct belief together with your readers over the long run.
That being stated, let’s check out the best way to merely show your most commented posts in WordPress utilizing 2 strategies. You’ll be able to click on the hyperlinks under to maneuver to any part:
Technique 1: Show Most Commented Posts With a Plugin in WordPress (Really useful)
There are a lot of totally different WordPress widespread posts plugins that you should use to show your widespread articles, however the easiest to make use of is MonsterInsights.
It’s the very best analytics answer for WordPress, utilized by over 3 million web sites. With this plugin, you may simply show your most commented posts anyplace in your web site.
The very first thing it’s worthwhile to do is set up, activate, and arrange MonsterInsights. For extra particulars, see our newbie’s information on the best way to set up Google Analytics in WordPress.
Observe: there’s a free model of MonsterInsights, however we’re utilizing the professional model for this tutorial because it contains the favored posts characteristic.
Upon activation, navigate to Insights » Widespread Posts after which click on the ‘Widespread Posts Widget’ tab within the menu.

On this display screen, you’ll management the looks of your most commented posts.
Merely choose the ‘Theme’ you need to use to your most commented posts. The theme operates equally to your WordPress theme and can management the general design of probably the most commented posts widget.
There are a ton of different customization choices on this display screen as effectively.
For instance, within the ‘Theme Preview’ meta field, you may show your most commented posts in a ‘Broad’ format under your content material or a ‘Slim’ format to the correct of your content material.

After that, you have got extra choices for customizing the design.
For instance, you may change the dimensions and colour of the title, icon, and background.

MonsterInsights will mechanically save any adjustments you make to your most commented posts show settings.
When you’re completed customizing the looks of your commented posts, it’s time to show your widespread posts by feedback.
Within the ‘Type By’ meta field, merely choose the ‘Feedback’ button.

Subsequent, you may scroll down and think about extra choices to incorporate and exclude posts.
There may be additionally an possibility to incorporate posts from particular classes within the widespread put up widget.

MonsterInsights will mechanically show your most commented posts.
You’ve got just a few totally different choices for including your widespread posts to WordPress. You’ll be able to select guide or automated placement.
If you happen to select ‘Automated’ placement, then the plugin will add your most commented WordPress posts immediately after the final paragraph of your weblog posts.

The opposite possibility is to show your most commented posts manually. If you choose the ‘Handbook’ possibility, then you may add the favored posts widget with a Gutenberg block or a shortcode.
To do that, open up a web page or put up the place you need to show your most commented posts.
As soon as contained in the content material editor, simply click on the ‘+’ icon and choose the ‘Widespread Posts’ block.

This may mechanically add your most commented posts to your web page.
Be sure you click on ‘Replace’ or ‘Publish’ to make your adjustments reside.

Now when your customers go to the web page, they may see your most commented posts displayed.
You’ll be able to go to the web site to see the most well-liked posts with feedback in motion.

Technique 2: Show Most Commented Posts Utilizing Code
The second technique includes including code to your WordPress information.
Nevertheless, there are some downsides to utilizing this technique. First, it includes including code to WordPress, so it’s not beginner-friendly. It might trigger critical issues with even a small error, so we advocate modifying WordPress core information for superior customers.
Second, the code isn’t as optimized for efficiency because the MonterInsights plugin. Which means it’s going to improve the server load, and it might probably decelerate your web site.
That being stated, let’s check out how one can show probably the most commented posts in WordPress with no plugin.
Including Code Snippet to capabilities.php File
You’ll need to add the code supplied under to your capabilities.php file. We advocate doing this by utilizing the WPCode plugin. It’s the most secure and greatest method so as to add customized code to your WordPress web site.
First, you will have to put in and activate the WPCode plugin. For extra particulars, please see our information on the best way to set up a WordPress plugin.
Observe: You may also use the free WPCode plugin because it has all of the options it’s worthwhile to add this code.
As soon as activated, you may head to Code Snippets » Add Snippet out of your WordPress dashboard and choose the ‘Add Your Customized Code (New Snippet)’ possibility.

Subsequent, you may add a reputation to your code snippet on the high of the web page. Now, simply copy and paste this code into the ‘Code Preview’ field:
// begin output buffering
ob_start();
?>
<ul class="most-commented">
<?php
// Run WP_Query
// change posts_per_page worth to restrict the variety of posts
$question = new WP_Query(‘orderby=comment_count&posts_per_page=10’);
//start loop
whereas ($query->have_posts()) : $query->the_post(); ?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> <span class="wpb-comment-count"><?php comments_popup_link(‘No Feedback;’, ‘1 Remark’, ‘% Feedback’); ?></span></li>
<?php endwhile;
// finish loop
?>
</ul>
<?php
// Flip off output buffering
$output = ob_get_clean();
//Return output
return $output;
}
// Create shortcode
add_shortcode(‘wpb_most_commented’, ‘wpb_most_commented_posts’);
//Allow shortcode execution in textual content widgets
add_filter(‘widget_text’, ‘do_shortcode’);
After that, ensure that to click on the Code Sort dropdown menu and choose the ‘PHP Snippet’ possibility.

As soon as that’s completed, merely click on the toggle to make the code ‘Lively’ after which press the ‘Save Snippet’ button on the high.
For extra particulars, please take a look at our newbie’s information to pasting snippets from the online into WordPress.
The code will run a database question and fetch 10 posts ordered by the best remark rely. Then, it makes use of output buffering to create a shortcode you should use to show the posts.
The final line of the code creates a shortcode that you should use in your posts, pages, and widget areas.
To show your widespread posts, all it’s worthwhile to do is add the next shortcode to your WordPress website.
[wpb_most_commented]
For extra particulars, see our newbie’s information on the best way to add a shortcode in WordPress.
If you wish to add thumbnails subsequent to your put up titles, then add the next line of code proper after <li> tag within the code above.
This code will outline the customized measurement for the put up thumbnail photos. You’ll be able to regulate the dimensions to fulfill your wants.
Fashion Your Most Commented Posts utilizing CSS
When you’ve completed that, you may model how your most commented posts will show.
To do that, you may modify the .most-commented and .wpb-comment-count CSS courses in your WordPress theme’s stylesheet.
You should use the next CSS to get began:
border-bottom:1px strong #eee;
padding-bottom:3px;
}
.most-commented li :after {
clear:each;
}
.most-commented img {
padding:3px;
margin:3px;
float:left;
}
.wpb_comment_count a, .wpb_comment_count a:lively, .wpb_comment_count a:visited, .wpb_comment_count a:hover {
colour:#FFF;
}
So as to add CSS to your web site theme’s stylesheet, you should use WPCode. Merely go to Code Snippets » Add Snippet out of your WordPress dashboard and choose the ‘Add Your Customized Code (New Snippet)’ possibility.

Subsequent, enter the CSS code underneath the Code Preview space and add a title to your snippet.
Simply make sure that you click on the Code Sort dropdown menu and choose the ‘CSS Snippet’ possibility.

Whenever you’re completed, don’t overlook to modify the toggle to ‘Lively’ after which click on the ‘Save Snippet’ button on the high.
For extra particulars, see our information on the best way to simply add customized CSS to your WordPress website.
We hope this text helped you show probably the most commented posts in WordPress. You may additionally need to see our final WordPress search engine optimisation information to get extra visitors, and our knowledgeable decide of the very best WordPress plugins for companies.
If you happen to favored this text, then please subscribe to our YouTube Channel for WordPress video tutorials. You may also discover us on Twitter and Fb.
The put up How you can Show Most Commented Posts in WordPress (2 Methods) first appeared on WPBeginner.


