How to display total views of all posts of one category?
Is there any way to display total views of all posts of one category? How to show that number on archive page? I have used this code to count views of each post:
function getPostViews($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');
return"0 Views";
}
return $count.' Views';}function setPostViews($postID){
$count_key ='post_views_count';
$count = get_post_meta($postID, $count_key,true);
if($count=='' || $count 0){
$count =0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key,'0');
}else{
$count = $count + 1;
update_post_meta($postID, $count_key, $count);
}
}
But how to count total views for one category and display it? Please help me!
Topic views categories archives Wordpress
Category Web