Display Post Views In WP Admin Posts Panel Without Any Plugin

Some of you might be already be familiar with a WordPress plugin called WP-PostViews, a plugin that displays the total number of views a particular post has had. But if you’ve reached over a thousand posts it can be hard for you to keep track of any recent developments, updates, and stats already.

Iftekhar Bhuiyan saw this “limit” so he decided to come up with a way to have the post views appear right inside the Admin panel in the posts section where you can basically see all the post titles, authors, date, tags, and other stuff. This way, even the authors will be able to monitor their posts and its total number of views.

NOTE: In order for this tutorial to work you’ll also need to use Iftekhar’s SNIPPET CODE for displaying posts views. Once you think you’re all set, proceed with the instructions below.

  1. Inside your WordPress Admin Panel, go to ‘Appearance’ then ‘Editor’.
  2. Select you theme’s functions.php file
  3. Copy and paste the code below.
<?php
add_filter('manage_posts_columns', 'posts_columns_id', 5);
add_action('manage_posts_custom_column', 'posts_custom_id_columns', 5, 2);
function posts_columns_id($defaults){
$defaults['post_views'] = __('Views');
return $defaults; }
function posts_custom_id_columns($column_name, $id){
if($column_name === 'post_views'){
echo getPostViews(get_the_ID());
} }
 ?>

4. Update the file then check the result by going to ‘Posts” then ‘All Posts’ and look at the last column to the right. You should see a column titled ‘Views’ (see screenshot below).

WP Post Views Display Post Views In WP Admin Posts Panel Without Any Plugin

If you experience difficulties making the code work or if you have any questions you’d like to ask Iftekhar, you can reach him through his Twitter or Google+.

Incoming search terms for the article:

Related Posts

Simple Chat Plugin

EWWW Image Optimizer

Twitter Cards PHP 1.1

Create An Effective RSS Feed With mPress WordPress Plugin