Technology

How to display popular posts by view count in WordPress (2 methods)

2025-03-20 10:42:43


If you've ever scrolled down to the end of our articles, you might have noticed the "Popular on WPBeginner Right Now!" widget, which helps readers discover the most valuable content and encourages them to explore our website further.


Displaying popular posts on a WordPress website not only helps users discover your best content but also increases engagement on the site, which may improve your website's SEO ranking on Google.


However, WordPress does not have a built-in feature to display popular posts based on the number of views. This article will introduce two methods to achieve this, including

  • Use the MonsterInsights plugin (recommended for beginners).
  • Use the code to display popular posts (suitable for those with coding knowledge).




Method 1: Display popular posts using the MonsterInsights plugin

Install and configure MonsterInsights

MonsterInsights is a Google Analytics plugin that features an easy way to display popular posts. You just need to install this plugin and connect it to your Google Analytics account.

Note: There is a free version of MonsterInsights, but the popular post features require the Pro version.


Choose the theme of the popular posts widget.

When you activate the plugin, go to Insights » Popular Posts and select "Popular Posts Widget." Then choose the theme of the widget you want. Some themes will have sample images of the posts, while others will look simpler.


Define the behavior of the widget.

Go to the Behavior section and select the method for filtering popular posts, such as

  • Show the most popular posts from Google Analytics (requires MonsterInsights Dimensions Add-On).
  • Show popular posts by the number of comments.


Additionally, you can choose the position to display the widget, such as

  • Automatically display in every post
  • Use the Gutenberg block to add to any page.
  • Show in the sidebar
  • Use Shortcode to embed it in the desired position.



Method 2: Display popular posts with code (for advanced users)

If you want more control and don't want to use a plugin, this method is for you. Use the WPCode plugin to add custom code.


Create a function to count the number of views.

Add PHP code to WPCode to record the number of times a post has been viewed:


Call the function to count the number of views.


Create code to fetch popular posts.


Show popular posts on the website.



Both methods can help you display popular posts in WordPress.  If you want the easiest method  MonsterInsights is the best option, but if you want maximum flexibility, using code is a good choice for you.

Leave a comment :