What's WP
Find Everything Related to WordPress - Best Tutoriasl on WordPress!
How to Track and Display WordPress Post Views Simply

How to Track and Display WordPress Post Views Simply

Post views are one of the most anticipated features of WordPress. Being an administrator of your WordPress site, you may desire to know how many people visit your pages and posts on a regular basis. But, as the WordPress post views feature is not offered by the core version of WordPress, you need to do a bit of hard work for tracking the views on each of your WordPress posts. Also, you can configure your site to showcase the exact number of visits on every page.

In this article, we have discussed the methods to track and display WordPress post views in your site.

Reasons to Display Post Views


Although post views do not bring any improvement in the SEO of a website or any performance-related benefits to the website, post views are checked by thousands of people. The main reason as to why you should track post views is to have a rough idea about the traffic that your site receives every day. People like to display it so that the visitors can be aware of the fact that a particular number of individuals have already come across the contents of a particular page.

Methods to Track and Display WordPress Post Views

There are two types of methods to track and display post views on your WordPress site. You can simply use a plugin or choose to perform various steps on your WordPress site to do it manually.

Track and Display WordPress Post Views Manually

The manual procedure for tracking and displaying the total number of views on each page is lengthy. However, it is the most recommendable method for enabling the views counting feature on your website because the scope for mistake is minimal. You can track the views on every page and display the pages or posts on the basis of total views. For example, you can add a filter into the codes to show the posts or pages with the maximum amount of views primarily, followed by the less visited posts.

priceBefore starting with the manual tutorial, it should be noted that this technique is slightly technical and requires proper execution of every step. Also, there are various codes that have to be entered accurately in the correct locations. Therefore, you must have a fair knowledge of using WordPress before implementing the steps discussed here in on your WordPress site.

To begin with, the first thing that you need to do is to create a technique for detecting and counting the traffic as soon as a visitor enters a page, post or website. The technique should be such that the views can be stored as a different custom field for each post. There is no need to get puzzled as all you need to do is to copy the following code into the function.php file of your activated theme.

technical support

It should be noted that if you are using a site-specific plugin, paste the above-mentioned code in that plugin. Upon the completion of this step, you need to bring the created function on a single page by using another code. This code can ensure that the function can be aware of the posts that should get credit for bringing in traffic. Therefore, you should navigate to a single post loop and enter the following code.


technical support

If you desire to create a child theme to make the things easier on your WordPress site, all you need to do is to add a tracker by using the wp-head hook. Proceeding further, you should now enter the following code in the function.php file of your theme.

technical support

The simply ensures the update of the newly created custom field whenever a visitor clicks on a post. However, you might notice that your website is not tracking the post views appropriately if you use a caching plugin. Therefore, you should make sure that the cache plugin you are using is compatible with this procedure. For ensuring, you can simply add the following code to your plugin.

technical support

This step marks the completion of the tracking procedure as post view counting can begin now. Although you can check the post views of your WordPress site, your visitors cannot witness it because the tool is not available on the front end of your WordPress. You can display the total views or the WordPress post views by adding yet another code to the theme’s functions.php file.

technical support

Now, you as well as your visitors can check the post views on your WordPress site.

Track and Display WP Post Views using Post View Stats Plugin

You can simply track and showcase your site’s post views by using an effective plugin such as Post View Stats plugin. It is a powerful tool that adds a widget to your site so that you can show your most popular post. It allows you to check the statistics of post views through a View count column. It is a premium plugin for WordPress that can be installed and activated easily by following a standardized procedure for installing plugins on WordPress.

Overall, you can track and display post views of your WordPress site by either following the manual procedure or the plugins method.


Eunge is the founder of WhatsWP.com. He has 15 years' experience on web development including ASP.NET, PHP and WordPress - worked for many famous international companies such as Microsoft, Autodesk, etc. He loves both front and back -end programming, and is keen on contributing on the WordPress community.