In WordPress, how do you keep track of how many times your posts have been viewed?

You’re a webmaster, and you’d want to keep track of your articles or see if anyone is interacting with your site? The simplest method is to combine the article with the view checking tool, which will allow you to quickly see how many people have viewed each blog post on your WordPress site.

When the number of views is higher than the others, readers may assess the quality of the article based on the number of views, and they will feel safer and want to click on the blog post to read it. So, in this article, I’ll show you how to count post views in WordPress using plugins or without plugins. Let’s have a peek now.

How to count post views without using plugins in WordPress

In the first place, go to the WordPress theme file Functions.php. Then copy the code below and add it to the file Functions.php before the closing tag?>.

function gt_get_post_view() {
    $count = get_post_meta( get_the_ID(), 'post_views_count', true );
    return "$count views";
function gt_set_post_view() {
    $key = 'post_views_count';
    $post_id = get_the_ID();
    $count = (int) get_post_meta( $post_id, $key, true );
    update_post_meta( $post_id, $key, $count );
function gt_posts_column_views( $columns ) {
    $columns['post_views'] = 'Views';
    return $columns;
function gt_posts_custom_column_views( $column ) {
    if ( $column === 'post_views') {
        echo gt_get_post_view();
add_filter( 'manage_posts_columns', 'gt_posts_column_views' );
add_action( 'manage_posts_custom_column', 'gt_posts_custom_column_views' );

Copy and paste your code in the while loop into the single.php file.

<?php gt_set_post_view(); ?>

Then copy and paste the following code where the number of views will be shown

<?= gt_get_post_view(); ?>

You will see the post view as follows when all is done:

Image Source: erfannoyon.com

How can you use a plugin to count post views in WordPress

Post Views Counter, built by dFactory, is the plugin I want to introduce. This plugin is one of the most often used plugins for WordPress post-views. It now includes over 90,000 operational facilities. This is an incredible number. You do not have to pay anything to receive this plugin, as it is FREE and can be downloaded from the homepage of the users.

Post Views Counter

It shows the number of times a post, a page or any sort of custom post was seen in a simple, quick and trustworthy method. It is version 4.0 or above compatible with WordPress. The plugin is easy to install with very little effort and to use, offering users the greatest experience.

Features include:

  • Free and open source
  • 2 methods of collecting post views data: PHP and Javascript
  • Option to select post types for which post views will be counted
  • Option to select page types for which page views will be counted
  • Enable to display post view count column for each of the selected post types
  • Option to set time between counts
  • Display views for each user type (logged in users, guests, selected user roles)
  • Exclude views for each type of visitors (robots, logged in users, guests, selected user roles)
  • Multiple post views position

To get this Post Views Counter, please check it here.

How to count WordPress post views by using the counter plugin for post views

First, as usual, the Post Views Counter plugin has to be activated and installed. To download the plugin click on the Download button to the left of the screen. Click to activate it thereafter.

Next, navigate to the Post Views Counter Settings =>. Here you may read the 2-tabs configuration interface: General and Display. You may start, the general tab, configure it to the following.

Count Post Views in website WordPress

The General tab includes:

  • Post Types Count: select the type of page you want to display the view counter (pages or posts)
  • Counter Mode: counting method, by PHP or JavaScript
  • Post Views Column: add a column that displays the number of views into the posts admin interface, page
  • Restrict Edit: limits the right to set a view counter (only Admin has permission)
  • Time Between Counts: enter the interval between 2 times to a user’s visit. You should leave it to 0
  • Reset Data Interval: Time to store counter data before being reset. You should leave it to 0
  • Flush Object Cache Interval: length of time to delete object cache. You should leave it to 0
  • Exclude IPs: don’t count visits from certain IPs
  • WP-PostViews: import counter data from the WP-PostViews plugin
  • Deactivation: enable to delete all plugin data when disabling the plugin

Click Save Changes to save after this.

Switch to the Display tab. You can set up it as below.

Count Post Views in website WordPress

The Display tab has the following options:

  • Post Views Label: label for the counter.
  • Post Type: the type of article you want to display the counter.
  • Page Type: the type of page you want to display the counter.
  • User Type: the type of user you want to count the number of article views.
  • Position: the position of the counter display. You can choose at the beginning, at the end of the article or manually insert using shortcode .
  • Display Style: display style. You can choose to display both the icon and the counter’s label or choose according to your preferences.
  • Icon Class: select the icon code for the counter. This counter uses the default Dashicon font of WordPress.

Click the Save Changes button to save it after you finished.

When you’ve done, this is what you will get the same result as before.


To summarize, these are two approaches to install WordPress postal view counters: use a plugin and use no plugin. For those not using code to display the number of views in the WordPress blog posts or pages, the Post View Counter plugin is easy and usable. So you can simply browse the articles or pages that you want with only a few clicks setup. We believe this article will enable you to show views on your website with your task. Thank you for reading.

Leave a Reply

Your email address will not be published.

Previous Story

Marvel Offers Secret Wars Creator Jim Shooter $10,000, Expects Film Adaptation

Next Story

Twitter Announces Coming Improvements to Direct Messages, Including Multi-DM Sharing and Improved Navigation