How to Display Most Popular Posts in WordPress

If you have a WordPress blog, displaying your most popular posts is a good way to promote some of your top content.

Displaying trending posts on your blog increases user engagement, which reduces bounce rate.

So, in this tutorial, we will provide a step-by-step guide on how to show popular posts in WordPress using plugins and non-plugin options.

Table of Content:

  • Benefits of Displaying Popular Posts in WordPress
  • Best Plugins To Display Popular Posts in WordPress
    • 1. Relevant
    • 2. WordPress Popular Posts
    • How to Show Popular Posts in WordPress Without a Plugin
  • Conclusion

Benefits of Displaying Popular Posts in WordPress

Here are a few reasons why you should display the most viewed posts in WordPress:

  • More User Engagement: Showcasing the trending posts on your WordPress site increases user engagement. Users who share, comment, and read your posts tend to spend more time on your website. And this is an important ranking factor.
  • Higher Traffic and Conversion: When users find and engage with the most relevant posts on your site, you get more page views which, when properly managed with tools like HubSpot, increases conversion.
  • Builds Social Proof: Showing trending posts on your website increases your credibility. It creates a sense of trust that you have content people find useful enough to engage with.

Best Plugins To Display Popular Posts in WordPress

WordPress does not have a native popular posts feature to show trending posts. This means you’ll have to manually write the code or use popular post plugins to showcase trending posts on your site.

In this section, we will show you how to display popular posts using two good plugins for that purpose. We’ll also show you how to manually display popular posts by writing custom code. Let’s begin.

1. Using Relevant Plugin

To use the Relevant plugin, you’ll first need to install and activate it on your site. To do this, go to Plugins >> Add New from your WordPress dashboard.

Next, type ‘relevant’ into the search bar. The plugin should appear on the search results. Click on Install Now next to the plugin name to install it.

Install plugin

Once done, the button changes to ‘Activate’. You’ll then need to click on this button to activate the plugin.

Activate plugin

After activating the plugin, you can access the plugin’s settings page by navigating to Relevant Posts >> Settings.

Plugin's settings page

With this plugin, you can display your WordPress blog’s related posts, latest posts, and trending posts. For this guide, we’ll use the Popular Posts option.

To get started, click on Popular Posts and customize the settings. You can set the title, number of posts, date range, and comments count.

Relevant post settings

When you scroll down, you’ll see additional options. You can set a placeholder image that will be used if the plugin detects no featured image for any post.

Set placeholder image

You can also choose to sort posts by the number of views or comments.

Sort posts

Once you’re done customizing the plugins’ options, click on Save Changes.

Save changes

After saving your changes, look under the Relevant Posts Shortcodes section. You’ll see a list of available shortcodes you can use to display content on your site. The code for showing trending posts is [bws_popular_posts] as seen below.

Copy shortcode for displaying popular posts

Copy this code as we’ll be using it in the next section.

Displaying Popular Posts on Your Sidebar

Your blog’s sidebar is a great place to show trending posts as it increases visibility.

To use this option, navigate to Appearance >> Widget and click the + button under ‘Sidebar Widget Area’.

Next, search for ‘shortcode’ and click on it.

Add shortcode widget

After that, add the code [bws_popular_posts] to the shortcode box. Then click Update to save your changes.

Update changes

Your most engaged posts should now show on the sidebar.

Post displayed in sidebar

Showing Popular Posts Using the Gutenberg Block Editor

Shortcodes provided by the Relevant plugin can also be used to show popular blog posts on your WordPress posts and pages. You can add it to new or existing pages on your site.

To do that, open the page you wish to edit or go to Page >> Add New to create a new one. In the post editor, add a title for the page. Then click the add block + icon in the content area.

Edit page

Next, search for the shortcode block and click on it.

Shortcode block

After that, paste the code [bws_popular_posts] into the shortcode box and click Preview to view your page.

Paste shortcode

Your trending posts will now show on the page you added the shortcode. You can also add this shortcode in the middle or at the bottom of your posts or pages.

Trending posts shown on page

Showing Popular Posts Using the Classic Editor

If you are on the classic editor, you can also add most viewed posts to your pages and posts.

For this, click the [ ] Add BWS Shortcode button from the classic editor.

[ ] Add BWS Shortcode button

Next, select Popular Posts and then click on Insert.

Click Insert

When you preview your changes, you should see your trending posts on the page.

Popular posts added to site

2. Using WordPress Popular Posts Plugin

This is another great option for showcasing popular posts in WordPress.

The plugin has customization options for displaying posts based on views, shares, time frames, tags, and authorship. And it is also compatible with custom post types.

To use the WordPress Popular Posts plugin, follow the steps below:

First, navigate to Plugins >> Add New and enter ‘WordPress Popular Posts’ into the search bar at the top right corner.

After that, click Install Now next to the plugin name. Be sure to activate the plugin once the installation completes.

Install and activate plugin

Showing Popular Posts in the Sidebar

To use the plugin, go to Appearance >> Widgets and click the dropdown arrow.

We want to display our trending posts in the sidebar section, so select the sidebar widget.

Widgets page

Next, click the +Add block icon and enter ‘WordPress Popular Posts’ into the search bar. Click on it when it appears.

Add block icon

After that, customize your widget by adding a title, post limit, and time range. Make sure you change the time range to ‘all-time’ to display your older posts.

Customize widget

You can further customize the widget to fit your taste. Once you complete all settings, click Update to save your changes.

Update changes

Side note: If you’re using the classic widgets option on your WordPress installation, you’ll need to add the WordPress Popular Posts widget to the area you wish to display it (see image below).

Add WordPress Popular Posts widget

Using the WordPress Popular Posts Plugin in the Block Editor

The Popular Posts block allows you to display popular posts anywhere on your WordPress website.

For example, you can show popular posts on your WordPress posts and pages. To do that, navigate to Pages >> Add New from your WordPress dashboard.

Add new page

Next, click the + Add block button and enter ‘popular posts’ into the search bar. After that, click on the WordPress Popular Posts block when it appears.

WordPress Popular Posts block

Next, select a title for your trending post widget. Also, select the All-time time range from the ‘TIME RANGE’ dropdown. After that, choose which post type to add and select your post sorting criteria.

Customize the block

Scroll down and further customize the block. Finally, click on the Publish button to save your changes.

Publish changes

You have now added the popular posts block to your page.

Popular posts block added to page

Side Note: If you’re using a caching plugin, you may get the error message ‘sorry, no data so far’. This happens because this plugin is currently incompatible with caching plugins such as w3 total cache. A quick walkaround for this is to clear your server cache.

How to Show Popular Posts in WordPress Without Plugins

Using plugins is the easiest way to show trending posts on your WordPress blog.

That said, some tech-savvy bloggers prefer the manual route because of its customization options. Not to mention, it also reduces the need to install plugins for little tasks.

The workaround for users who don’t want to add additional plugins to their site is to use custom code.

Note: This method is ideal for tech-savvy users with some knowledge of PHP. If you don’t have the experience, consider using the plugin method explained above. Also, we’re making changes directly to the theme files for this guide. However, we recommend creating a child theme so you won’t lose any custom code when you update your theme.

To start, log in to your WordPress website and navigate to Appearance >> Theme File Editor.

Theme File editor

Next, locate the functions.php file under Theme Functions and click on it.

functions.php file

Add the code snippet below at the end of the file. function wp_display_popular_posts($num_posts = 5) { $popular = new WP_Query(array(     ‘posts_per_page’ => $num_posts,     ‘meta_key’ => ‘post_views_count’,     ‘orderby’ => ‘meta_value_num’,     ‘order’ => ‘DESC’ )); if ($popular->have_posts()) {     while ($popular->have_posts()) {         $popular->the_post();         //To Customize the display of trending posts as needed         echo ‘<h2><a href=”‘.get_permalink().'”>’.get_the_title().'</a></h2>’;     } } wp_reset_postdata(); }

After adding the code snippet, click Update File to save your changes.

Display popular posts custom code

The code above uses the WP_Query function to loop through posts and filter based on post views count.

To display your trending posts, you need to call the wp_display_popular_posts function where you want to display the posts.

We’ll use the sidebar for this example. To use this option, locate sidebar.php from your theme files under the sidebar menu. Click on it and add the code below at the end of the file. // you can change (5) to the number of posts you want to display e.g (3). <div class=”popular-posts”> <h3>Popular Posts</h3> <?php wp_display_popular_posts(5); ?> </div>

Code to show popular posts in the sidebar area

Click the Update File button after adding the code to save your changes.

You have now successfully added the popular post widget to your website without using a plugin. You can view the changes on your website’s frontend.

Showing popular posts on the frontend

Conclusion

Displaying trending posts on your website attracts visitors and makes them spend time engaging with your most popular content.

In this tutorial, we have identified some of the best ways to display most viewed posts on your website using plugins and manually with custom code.

Showing trending posts is one way to boost user engagement and drive traffic to your WordPress site. For more tips, check out our guide on how to grow your WordPress site’s traffic.

Leave a Reply

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