WP Popular Postsを使った人気順のループ
if(class_exists('\WordPressPopularPosts\Query')):
global $post;
$args = array(
'range' => 'all', //計測期間
'post_type' => 'post',
'limit' => 5, //表示数
);
$wpp_query = new \WordPressPopularPosts\Query($args);
$wpp_posts = $wpp_query->get_posts();
if($wpp_posts):
?>
<ul>
<?php
foreach($wpp_posts as $wpp_post):
$post = get_post($wpp_post->id);
setup_postdata($post);
?>
<li></li>
<?php
endforeach;
wp_reset_postdata();
?>
</ul>
<?php endif; ?>
<?php endif; ?>