以下格式的帖子列表:
作者的帖子浏览量:作者姓名(15)帖子标题(67)帖子标题(4)总浏览量:86
$author_id = \'\'; // do stuff to get user ID
$author_posts = get_posts( array(
\'author\' => $author_id
) );
$counter = 0; // needed to collect the total sum of views
echo \'<h3>Post views by Author:</h3><ul>\'; // do stuff to get author name
foreach ( $author_posts as $post )
{
$views = absint( get_post_meta( $post->ID, \'views\', true ) );
$counter += $views;
echo "<li>{$post->post_title} ({$views})</li>";
}
echo "</ul><hr /><p>Total Number of views: <strong>{$counter}</strong></p>";