集計用テンプレートを作成、以下を記述
<div class="widget"> ユーザー別投稿数ランキング <?php $args = array( 'orderby' => 'post_count', 'order' => 'DESC', ); $users = get_users($args); if (!empty($users)) : echo '<ul>'; foreach ($users as $user) : $my_posts = get_posts('numberposts=-1&author='.$user->ID); $n = count($my_posts); ?> <li> <?php echo get_avatar( $user->ID, $size = '60'); ?> <a href="<?php echo get_author_posts_url( $user->ID); ?>"><?php echo esc_html($user->display_name); ?></a>(<?php echo $n; ?>) <div class = "clear-left"></div> </li> <?php endforeach; echo '</ul>'; endif; ?> </div>
サイドバーにベスト3
<p> ユーザー別投稿数ベスト<span class="Count">3</span></p><?php $args = array( 'orderby' => 'post_count', 'order' => 'DESC', 'number' => 3, ); $users = get_users($args); if (!empty($users)) : echo '<ul>'; foreach ($users as $user) : $my_posts = get_posts('numberposts=-1&author='.$user->ID); $n = count($my_posts); ?> <li> <?php echo get_avatar( $user->ID, $size = '60'); ?> <a href="<?php echo get_author_posts_url( $user->ID); ?>"><?php echo esc_html($user->display_name); ?></a>(<?php echo $n; ?>) <div class = "clear-left"></div> </li> <?php endforeach; echo '</ul>'; endif; ?>
参考サイト ja.forums.wordpress.org…