How to Show WordPress Post View Count

WordPress post view count


I would like to show the number of reads in WordPress posts (on the home page). But there are very few themes which have the same feature. Is any plugin required for that?
Several WordPress plugins are available to show post views or count.
They are,
WP-PostViews WordPress plugin
Just configure this plugin via Admin -> Settings -> PostViews
Find this line

<?php while (have_posts()) : the_post(); ?>

In your WordPress theme template file.
Add this line

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

after the above code to show the counter.
Other good plugins are.
Simple Post view counter
Best plugin to display how many times a post has been viewed.
Jetpack post views
show post views in your sidebar widget.
These are free WordPress plugins.
Alter Way ( Display post views without plugin)
Add this code in your theme function.php file

function getPostViews($postID){
	$count_key = 'post_views_count';
	$count = get_post_meta($postID, $count_key, true);
	if($count==''){
		delete_post_meta($postID, $count_key);
		add_post_meta($postID, $count_key, '0');
		return "0 View";
	}
	return $count.' Views';
}
function setPostViews($postID) {
	$count_key = 'post_views_count';
	$count = get_post_meta($postID, $count_key, true);
	if($count==''){
		$count = 0;
		delete_post_meta($postID, $count_key);
		add_post_meta($postID, $count_key, '0');
	}else{
		$count++;
		update_post_meta($postID, $count_key, $count);
	}
}
// Remove issues with prefetching adding extra views
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);

Next, you need to set up a post view count. Just place this code below within the single.php inside the WordPress loop.

<?php
		  setPostViews(get_the_ID());
?>

If you want to display post views, add this code within the loop.

<?php
		  echo getPostViews(get_the_ID());
?>