#DiwakarAcademy #WordPressTutorial #ViewCount
Hello Friends,
I am going to show How to Display Total Views on WordPress Posts without Plugin.
function da_get_views_post($post_id){
$key = 'post_views_count';
$count = get_post_meta($post_id,$key, true);
if($count == ''){
$count = 0;
delete_post_meta($post_id,$key);
add_post_meta($post_id,$key,$count);
}else{
$count++;
update_post_meta($post_id,$key, $count);
}
}
function da_get_post_views($post_id){
$key = 'post_views_count';
$count = get_post_meta($post_id,$key, true);
if($count == ''){
$count = 0;
delete_post_meta($post_id,$key);
add_post_meta($post_id,$key,$count);
return "0 View";
}
return $count. ' Views';
}
//add single.php file to increase view count
da_get_views_post(get_the_ID());
//Display total view count
echo da_get_post_views(get_the_ID());
how to check post views on wordpress,wordpress display posts,how to see post views on wordpress,wordpress popular posts plugin,content views plugin wordpress,how to track and view wordpress post and site views and visits,post views counter wordpress,display wordpress posts on page,wordpress,wordpress popular posts,how to display total views of posts in wordpress