Generally, top 10 posts in a website will bring more than half of the traffic. In such a case, it is a good idea to promote those popular posts in a sidebar or footer area as a site wide widget. There are special popular posts plugins available or you can use common plugins like Jetpack for this purpose. However, popular posts widget do not show the view count for each post and you can only show limited items in the list. The best option is to showcase the number of post views for each post. This helps readers to easily understand the popularity of the page they are reading. In this article, we will explain how to show number of post views in your WordPress site.
Post Views Count – Plugin Vs Theme
Using a plugin is the easy and recommended way to show number of views for each post. However, you may need to manually style the output or use a shortcode. To make things simple, there are also themes come with in-built support for post view counter in the meta data. These themes either use a plugin from WordPress.org repository or use custom functions to do the same work.
1. Using Post Views Counter Plugin
Post Views Counter is a completely free and open source plugin with more than 200K active installations. It will record each user’s visit and allow you to showcase the count anywhere as a shortcode. Go to your admin dashboard, install and activate the Post Views Counter plugin. Learn more on how to install a plugin in WordPress. Go to “Settings > Post Views Counter” section to view the available options and configure the usage.
Under “General” tab, you can configure the followings:
- Post Types Count – the plugin will show all post types available on your site including custom post types. Make sure to choose only the required post types to include for the count.
- Post Views Column – enable this to add a new column showing number of views in the selected post type. For example, if you have selected “Posts” for “Post Types Count”, then you can go to “Posts > All Posts” in admin panel to see a “Post Views” column added in that page.
- Restrict Edit – enable this to allow manual editing of post views only for administrator roles.
- Count Interval – select time duration to count single user visit. For example, 24 hours means a post visit from user will be counted only once in a day.
- Reset Data Interval – delete the count and reset to 0 after the mentioned interval. Set as 0 to retain all data without resetting.
- Flush Object Cache Interval – set 0 to disable this feature. It works if you have object cache enabled using plugins like W3 Total Cache. In such a case, the view count will be stored in the cache before being pushed to the database.
- Exclude Visitors – you can exclude robots, logged in users, guests or any other specific user role. For example, you can exclude author, contributor or customer roles after selecting “Specific User Role” checkbox.
- Exclude IPs – add IP addresses to exclude from counting the view from those IPs. For example, you can add your own IPs to avoid including your own visits.
- Strict Counts – enable this to prevent bypassing count in incognito views.
- Tools – use this option to import views from WP-PostViews plugin. You can also delete all the currently recorded views by clicking on “Delete views” button.
- Deactivation – if you decided to delete the plugin, make sure to check this box to delete all database entries.
You can configure the followings under “Display” section.
- Post Views Label – change the text to show before the count.
- Post Type – select the post type to output the view count.
- Page Type – select page type for output support, generally “Single pages” is what you need.
- User Type – use this to hide the count from logged in users, guests or for any specific role.
- Position – this is the important setting to show the counter. You can show automatically either before the content or after the content. There is also “Manual” option available which you can use to insert the counter manually using a shortcode.
- Display Style – select icon or label or both for showing before the count.
- Icon Class – select the dashicon icon CSS class to use it before the count.
- Toolbar Chart – enable this to view a chart on top admin bar when editing a post. You can hover on the chart to find total number of views for the post you are editing.
As you can see, this simple plugin has numerous options for configuring the setup. Below is how it shows with before the content position.
If you want to manually output the post views, you can use the [post-views] shortcode.
2. Using Theme to Show Post Views
Pixwell is a premium modern magazine theme which supports showing post views as a meta data. This theme uses the same Posts Views Counter plugin but the advantage is that you do not need to worry about displaying the output. The theme will automatically output the count as a post meta data along with other details below the post title. If needed, you can also manually output the count in different location using shortcode as mentioned above.
- Install and activate Pixwell theme on your site. The theme will ask you to install the required plugins for the demo you choose to import. Make sure to install and activate Post Views Counter plugin from “Appearance > Install Plugins” section or while importing the demo content.
- Go to “Theme Options > Styles & Design” section and enable “View Icon” option. This will allow the theme to show the dashicon you set in plugin’s “Display” setting before the counter.
- After that, go to “Single Post > Styles & Design” section and drag the “View” button from “Disabled” column to “Enabled” section. If “View” button is already added in “Enabled” column, you do not need to do anything.
Save you changes and check any post from your site. The theme automatically will use the Posts View Counter plugin and show post view counter in the meta data like below.
You can also find a dashboard widget in admin panel showing post views count in a daily chart along with a list of posts and their views.
Updating Post Views for Single Post
Another advantage of using Pixwell theme is that it offers an option to manually enter a fake count value. The theme offers a meta box in post editor to enter fake value for single posts.
Frequently Asked Questions
Whether you use a plugin or theme, each visit to the post needs to be recorded in database for increasing the count. Post Views Counter plugin will create a table in your database with the name as “wp_post_views” to record all visits. You can fetch the count from database and showcase anywhere on the site using a shortcode.
Yes, as the data needs to be fetched from the database for each page load. However, the impact will not be noticeable for smaller sites.
Yes, you can use the data to find or show the most popular posts based on the visits. You can check the dashboard widget or use the additional column in the “Posts > All Posts” admin page. Themes like Pixwell also offers widgets using Post Views Counter plugin to showcase popular posts for a month, week and all time.
The simple solution is to reset the count from plugins “General” settings page. If you do not want to delete all data, it is also possible to delete partial data directly from the table.