The way to Show Standard Posts by Views in WordPress (2 Methods)

No Comments

Do you wish to show widespread posts by views in WordPress?

Displaying your widespread posts may help you generate extra visitors, hold guests in your website longer, and construct social proof.

On this article, we’ll present you the way to show your widespread posts by views in WordPress, each with and and not using a plugin.

Why Show Standard Posts by Views in WordPress?

Typically it may be arduous in your guests to search out your greatest content material. Even your hottest articles can get misplaced when you’ve gotten 1000’s of weblog posts.

Displaying your hottest posts permits you to present your hottest articles anyplace throughout your WordPress weblog.

Your widespread posts are essentially the most profitable items of content material for a cause. By displaying these to your guests, you’ll construct belief, enhance social proof, and make sure that your guests keep in your web site longer.

When your guests keep in your WordPress web site longer, this offers you extra time to persuade them to make a purchase order, be part of your electronic mail publication, or take one other motion.

With that stated, let’s check out the way to merely show widespread posts by views in WordPress utilizing 2 strategies.

Click on on the short hyperlink to leap straight to your most well-liked methodology:

Show widespread posts by views utilizing a plugin
Show widespread posts by views and not using a plugin

Methodology 1: Show Standard Posts by Views With a Plugin in WordPress

There are numerous WordPress widespread posts plugins that you need to use to show your hottest content material, however the best plugin to make use of is MonsterInsights.

MonsterInsights is the greatest analytics resolution for WordPress utilized by over 3 million web sites. It permits you to merely show your widespread posts anyplace in your WordPress website.

You too can use the Inline Standard Posts characteristic to point out your widespread posts immediately inside your content material.

Very first thing you want to do is set up the plugin. For extra particulars, see our step-by-step information on the way to set up Google Analytics in WordPress for freshmen.

Word: there’s a free model of MonsterInsights out there, however we’ll be utilizing the professional model because it consists of the favored submit characteristic.

Upon activation and arrange, go to Insights » Standard Posts after which click on the ‘Standard Posts Widget’ menu merchandise.

On this display screen, you may choose the favored submit fashion you wish to use. It will management the looks of your widespread posts.

There are loads of extra customization choices as properly.

For instance, underneath the ‘Theme Preview’ meta field, you may show your widespread posts in a ‘Extensive’ format beneath your content material, or on the proper hand facet of your web page with the ‘Slender’ possibility.

Subsequent, you may change the colour and measurement of the submit title, writer, and date.

The ‘Widget-Format Choices’ menu will change the the variety of columns which can be displayed. There are extra show choices you may customise on this display screen as properly.

MonsterInsights will mechanically save all settings after you make a change.

When you’ve personalized the looks of your widespread posts, you’ll have just a few completely different strategies for including them to WordPress.

Within the ‘Embed Choices’ meta field, there are 4 completely different show choices. You may even use a number of show choices collectively. The only means is popping on the ‘Computerized Placement’ toggle.

You too can show widespread posts utilizing Gutenberg Blocks within the new WordPress editor, with a shortcode, or by including the widget to a sidebar.

To show your widespread posts utilizing Gutenberg Blocks open up a submit or web page you wish to edit.

After that, click on the ‘Add Block’ icon.

Seek for ‘widespread posts’ within the search bar after which select the ‘Standard Posts’ or ‘Inline Standard Posts’ possibility.

Then, in the proper hand sidebar, you may additional customise the looks of your widespread posts.

The settings are just like the settings from the MonsterInsights plugin menu we highlighted above.

After you’ve completed including and customizing the looks of your widespread posts, be sure to click on ‘Publish’ or ‘Replace’ to save lots of your adjustments.

Now, your guests will see your widespread posts once they go to your web site.

Methodology 2: Show Standard Posts by Views With no Plugin in WordPress

Should you don’t wish to use a plugin, otherwise you’re already utilizing too many plugins, then you need to use this code methodology.

There are some downsides to utilizing this methodology. First, it includes including code to WordPress, and it’s not newbie pleasant.

Second, the code methodology isn’t as efficiency optimized as MonsterInsights plugin, so it’ll improve server load and might decelerate your website when you have loads of content material.

With that stated, let’s check out the way to add widespread posts in WordPress and not using a plugin.

On this methodology, you’ll want so as to add code to your WordPress information. Should you haven’t finished this earlier than, then try our newbie’s information to pasting snippets from the online into WordPress.

Now that you understand how so as to add code in WordPress, let’s go forward and add the next code to your features.php file, in a site-specific plugin, or by utilizing a code snippets plugin.

operate wpb_set_post_views($postID) {
$count_key = ‘wpb_post_views_count’;
$rely = get_post_meta($postID, $count_key, true);
$rely = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, ‘0’);
update_post_meta($postID, $count_key, $rely);
//To maintain the rely correct, lets do away with prefetching
remove_action( ‘wp_head’, ‘adjacent_posts_rel_link_wp_head’, 10, 0);

The code above will detect submit view counts and retailer it as a customized area for every submit.

When you add that operate to WordPress, you want to name the operate in your single submit pages. Now, you want to inform the operate which submit will get credit score for the views.

To do that, copy and paste the next code inside your single submit loop.


In case you are utilizing a baby theme, otherwise you simply wish to make issues simple for your self, then it’s best to merely add the tracker in your header by utilizing wp_head hook.

To do that paste the next code in your theme’s features.php file or the site-specific plugin (as proven above):

operate wpb_track_post_views ($post_id) {
if ( !is_single() ) return;
if ( empty ( $post_id) ) {
international $submit;
$post_id = $post->ID;
add_action( ‘wp_head’, ‘wpb_track_post_views’);

After getting positioned this, each time a person visits the submit, the customized area shall be up to date.

Word: In case you are utilizing a caching plugin, then this system is not going to work by default. You might use Fragmented Caching characteristic that’s provided by some superior caching plugins to bypass the caching plugins.

Now, you are able to do all kind of cool stuff comparable to show submit view rely, or type posts by view rely. Let’s check out the way to do a few of these cool issues.

You may show the submit view rely in your single submit pages, typically subsequent to the remark rely, or your social share buttons.

To do that, add the next in your theme’s features.php file or the site-specific plugin (highlighted above).

operate wpb_get_post_views($postID){
$count_key = ‘wpb_post_views_count’;
$rely = get_post_meta($postID, $count_key, true);
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, ‘0’);
return “0 View”;
return $rely.’ Views’;

Then inside your submit loop add the next code:


If you wish to type the posts by view rely, then you are able to do so simply by utilizing the the wp_query post_meta parameter.

Probably the most primary instance loop question would seem like this:

$popularpost = new WP_Query( array( ‘posts_per_page’ => 4, ‘meta_key’ => ‘wpb_post_views_count’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’ ) );
whereas ( $popularpost->have_posts() ) : $popularpost->the_post();



So as to add different WP_Query parameters comparable to time vary, confer with the WP_Query web page within the Builders Handbook.

We hoped this text helped you learn to show widespread posts by views in WordPress. You may additionally wish to see our information on the way to enhance your WordPress web optimization rankings, and our professional picks of the will need to have WordPress plugins for enterprise web sites.

Should you appreciated this text, then please subscribe to our YouTube Channel for WordPress video tutorials. You too can discover us on Twitter and Fb.

The submit The way to Show Standard Posts by Views in WordPress (2 Methods) appeared first on WPBeginner.

    About Marketing Solution Australia

    We are a digital marketing company with a focus on helping our customers achieve great results across several key areas.

    Request a free quote

    We offer professional SEO services that help websites increase their organic search score drastically in order to compete for the highest rankings even when it comes to highly competitive keywords.

    Subscribe to our newsletter!

    More from our blog

    See all posts

    Leave a Comment