2 Ways to Add Dynamic Number of Post Views With or Without a Plugin

This tutorial shows you 2 ways to display the number of times a post has been viewed in any theme position.

  1. The 1st method uses a plugin.
  2. The 2nd method uses code which is restricted to logged in members of WP Sites only.

1. Post Views Plugin

Lester Chan has developed one of the best plugins for displaying post views using one of many different methods.

Once you install the plugin, you can display the post view count using the plugins settings or call the function using a variety of methods.

Here’s the template tag you can add to any template file.

<?php if(function_exists('the_views')) { the_views(); } ?>

If you use a theme like Genesis, you can create a shortcode which you can then add to the post info using a genesis filter. The code for this solution is included in the 2nd method.

2. Add Post Views Using Code

This method provides the code you can simply add to your child themes functions file.

Then all you need to do is display the post views count using one of several easy to use methods included in the following code for members of WP Sites only.

Related Code Snippets

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.