Skip to content
Mc Starters Main Logo Circle
  • Home
  • Our Services
  • Download Templates
  • Guest Posts
  • Contact Us
  • Tools
Mc Starters Main Logo Circle

Home \ WordPress \ How to Display Total Views on Your WordPress Posts: A Step-by-Step Guide

How to Display Total Views on Your WordPress Posts: A Step-by-Step Guide

Published By :Iram S. December 5, 2023January 10, 2024 WordPress
How to Display Total Views on Your WordPress Posts A Step-by-Step Guide

Do you want to display total views on WordPress posts? Here a quick methods to display post views with plugins and without plugins.

Displaying post views on WordPress posts to add value to your services. If you give the product review or any advertisement is a great fit to show the post views. In this way, every visitor sees your traffic and may be impressed to reach out to discuss pricing or details.

You can easily display post views counter up or bottom of the blog post, where you want.

Let’s get started:

Display Post Views With Plugins

If you do not know the coding or technical skills, you can display the total views on WordPress posts with plugins.

Post Views Counter

Post Views Counter

Post views counter is a compatible and reliable plugin that you use to display post views or visitors. It can pull the data in different ways, what you want to like. Go to the plugin’s display settings, and customize the style or positions of the view counter.

Page View Count

Page View Count

Page view count displays the number of page and post views. Go to plugins display settings and change the design of the plugins just show the post views. It can increase the engagement of the users. You can change the color according to color themes.

Affiliate Banner 1

Display Post Views Without Plugins

You can display the page views with code by making a just few changes in themes.

To add code to your WordPress site for displaying post views, follow these steps:

Step 1: Log in WordPress admin dashboard.

See also  What is Squeeze Landing Page ( 10 + Free Squeeze Pages Templates )

Step 2: Go to Appearance, then open Theme Editor.

Step 3:Open the functions.php file.

Step 4: Copy and paste the these code 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);
    $count++;
    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');

Step 5: Open the single.php file in the theme editor.

Step 6: Copy and paste this code in the while loop (use CTRL + F or Command + F to find it in the file):

Affiliate Banner 2

<?php gt_set_post_view(); ?>

This code is responsible for incrementing the views count each time a post is viewed.

Step 7: Copy and paste this code where you want to display the number of posts or page views:

<?= gt_get_post_view(); ?>

This will display the views count on the front end of your site​​.

By adding this code to your WordPress site, you will be able to track and display the number of views each post receives, which can be valuable for understanding the popularity and reach of your content.

WordPress post view count not working

If your WordPress post view count is not working, there could be several reasons for this issue. Here are some steps you can take to troubleshoot and resolve the problem:

  1. Update the view count plugin and check its settings.
  2. Clear both the website and browser cache.
  3. Temporarily switch to a default WordPress theme.
  4. Check for JavaScript errors in the browser console.
  5. Consult your hosting provider about server-side restrictions.
  6. Ensure WordPress and PHP are up to date.
See also  How to Increase icon size within toggle widget Elementor

conclusion

In conclusion, displaying total views on WordPress posts involves adding custom PHP functions to your WordPress theme. These functions are responsible for tracking the number of times a post is viewed and displaying this count on the front end of your website.

By editing the functions.php file, you introduce a system to increment view counts and retrieve them for display. Additionally, the code can be extended to modify the WordPress admin dashboard, allowing view counts to be visible in the post-management area. This feature enhances the functionality of a WordPress site by providing valuable insights into post popularity and engagement.

You Might Also Like

Flyingpress Review The Best WordPress Performance Plugin 2024

FlyingPress Review (2025)

Key Elements To A Successful WordPress Website

Key Elements To a Successful WordPress Website| 2024

Post Tags: #WordPress#Wordpress guide#WordPress Posts
Facebook FacebookTwitter TwitterInstagram InstagramPinterest PinterestYouTube YouTube

Categories

© 2025 Mc Starters Blog

  • Guest Posts
  • HTML Sitemap
  • XML Sitemap
  • Affiliate Disclosure
Get Professional Websites
  • Home
  • Our Services
  • Download Templates
  • Guest Posts
  • Contact Us
  • Tools
Facebook X Instagram YouTube Pinterest
Search