post_views_count returns 0
-
Hi I am trying to list authors based on view counts. I got the authors using get_users and the posts using get_posts but when I pass the post id into get_post_meta, all it returns is 0.
$users = get_users('orderby=post_count&order=DESC&who=author&number=10'); foreach($users as $user) { $query = get_posts(array('author' => $user->ID) ); foreach ($query as $post) { $views = absint( get_post_meta( $post->ID, 'post_views_count', true ) ); echo $views; } }I can see view in my blog for each post but when I go to wp_postmeta table in my database, I have only few post_views_count meta keys and all the meta_values are 0.
Am I doing anything wrong?
The topic ‘post_views_count returns 0’ is closed to new replies.