I'm looking to display the total views generated by each author on their author page. I can't find any php code that works. Can anyone help?
I've tried using this code:
<?php
$author_posts = get_posts( array('author' => $current_user->ID) );
$counter = 0; // needed to collect the total sum of views
foreach ( $author_posts as $post ) {
$views = absint( get_post_meta( $post->ID, 'post_views_count', true ) );
$counter += $views;
}
echo "{$counter}";
?>
but the number displayed stays on '0'. Am I doing something obvious wrong? Here's one of my author pages: http://fresharsenal.com/author/olipricebates/
Any help greatly appreciated! Also if anyone knows how to show the amount of shares generated that'd be ace