ThemeIM Blog Details

How to Post View Count WordPress without Plugin

How to post view count WordPress without plugin

Counting post views and displaying them in WordPress posts is an innovative way to let visitors know the value of the post. But you don’t need a plugin to do this simple task. That is where we will show you how to post view count in WordPress without plugins.

— It is very important for the content creator to let their audience know how many times the post has been reviewed by visitors. Adding a WordPress page view counter can be the easiest solution. There are hundreds of plugins for showing WordPress views. But you can still show post views without using any plugin.

Three simple steps to post view count WordPress without plugins

Let’s break down how to count post views and display them in WordPress.  In three steps you can add a WordPress page view counter. — Consequently, you can see how many visitors have visited a single post. And you may also learn how to get more views on WordPress.

So without further ado, let’s start with the first step,

Step 1 –

While your theme is activated, log into your WordPress dashboard by going to –

www.domain_name.com/wp-admin

Then, go to – Appearance >> Editor

Now, you will find the function.php file at the left sidebar. And put the following code inside the file –

function getThemeimPostViews($postID){ $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "0 View"; } return $count.' Views'; } function setThemeimPostViews($postID) { $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{ $count++; update_post_meta($postID, $count_key, $count); } }remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);

Step 2 –

Inside the single.php file,  add the following code snippet before the end while loop –

&lt?php
setThemeimPostViews(get_the_ID());
?>

Step 3 –

Now is for the final part. Copy and paste the final code inside the template where you would like to display the number of views –

&lt?php echo getThemeimPostViews(get_the_ID()); ?&gt

Is there any difference between views and visitors on WordPress?

While the terms – ‘views’ and ‘visitors’ may sound similar, there is a distinction between these two metrics. A page view is related to the loading of the browser while a visit counts when someone arrives at your website. The number of views increases as soon as a user reloads the page. So, a visitor can generate as many views as he wants.

To put it simply, if a single visitor goes to 3 blog pages of your website, the number of page views will be 3 but the number of visitors will be 1.

F.A.Q

What would be some of the best post view counter plugins?

Ans: Although adding a post view counter can be done with simple codes, there are many free and paid plugins that allow you to do this with more ease. Those who are not so familiar with coding, use the following plugins to add a WordPress post view counter –

  • WP-PostViews (Free)
  • Post Views Counter (Free)
  • Advanced Page Visit Counter (Free)
  • ExactMetrics (Paid)

What are post views in WordPress?

Ans: In a nutshell, the number of times a post appears on a visitor’s screen is called post view. Tracking and counting the post view is a very good practice to get an idea of the performance of the post. You can also think about ideas for generating more views on your post.

How much traffic is adequate for a blog?

Ans: Once a blog gains thousands of page views, it is better to set a 6% traffic goal for that particular blog. Increasing traffic levels will be easier when it begins with near zero traffic. For instance, the traffic level can be increased 10 times if a blog has 100 page views rather than 1000. Check out our blog on indexing your website in Google for more insights.

Summing Up –

We hope this article was useful enough to help you for adding post view count in WordPress without a plugin. You will successfully add this feature if you have implemented the above code accordingly. This way, you can display how many views your blog posts get without using any plugins.

Leave a comment below if you have any problem implementing the above codes. We will be glad to assist you with anything. Stay tuned for more insightful blogs like this one.

Editor Team

We are a group of WordPress experts (editorial team) from Themeim. All of these articles go through manual testing to reveal the ultimate outcome.

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.