您需要设置who
中的参数get_users
<?php
$blogusers = get_users( \'orderby=post_count&who=authors\' );
foreach ( $blogusers as $user ) {
echo \'<li>\' . esc_html( $user->display_name ) . \'</li>\';
}
?>
EDIT
看来我回答得太快了。您的问题和我的回答中的代码是您想要实现的目标的开始。
我现在没有时间编写代码,去看橄榄球赛,但这里是《214》中使用的完整代码,用于显示作者及其帖子数量。希望这有帮助
function twentyfourteen_list_authors() {
$contributor_ids = get_users( array(
\'fields\' => \'ID\',
\'orderby\' => \'post_count\',
\'order\' => \'DESC\',
\'who\' => \'authors\',
) );
foreach ( $contributor_ids as $contributor_id ) :
$post_count = count_user_posts( $contributor_id );
// Move on if user has not published a post (yet).
if ( ! $post_count ) {
continue;
}
?>
<div class="contributor">
<div class="contributor-info">
<div class="contributor-avatar"><?php echo get_avatar( $contributor_id, 132 ); ?></div>
<div class="contributor-summary">
<h2 class="contributor-name"><?php echo get_the_author_meta( \'display_name\', $contributor_id ); ?></h2>
<p class="contributor-bio">
<?php echo get_the_author_meta( \'description\', $contributor_id ); ?>
</p>
<a class="button contributor-posts-link" href="<?php echo esc_url( get_author_posts_url( $contributor_id ) ); ?>">
<?php printf( _n( \'%d Article\', \'%d Articles\', $post_count, \'twentyfourteen\' ), $post_count ); ?>
</a>
</div><!-- .contributor-summary -->
</div><!-- .contributor-info -->
</div><!-- .contributor -->
<?php
endforeach;
}
只需在模板文件中将其称为
twentyfourteen_list_authors();