Get total number of views for an author, on author page
-
Basically I am already doing this, but it only counts the last 5 posts. I want to show the views for all the posts.
<?php $author_id = $curauth->ID; // do stuff to get user ID $author_posts = get_posts( array( 'author' => $curauth->ID ) ); $counter = 0; // needed to collect the total sum of views foreach ( $author_posts as $post ) { $views = absint( get_post_meta( $post->ID, 'views', true ) ); $counter += $views; } echo "</ul><hr /><p>Total Number of views: <strong>{$counter}</strong></p>"; ?>
thank you
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Get total number of views for an author, on author page’ is closed to new replies.