您需要在中设置who
参数get_users
<?php
$blogusers = get_users( 'orderby=post_count&who=authors' );
foreach ( $blogusers as $user ) {
echo '<li>' . esc_html( $user->display_name ) . '</li>';
}
?>
编辑
似乎我正在快速回答。您的问题和我的答案中的代码是您想要实现的目标的起点。
我现在没有时间去编码,去看橄榄球,但是这里是在二十四岁时用来显示作者及其帖子数的完整代码。希望这可以帮助
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();