Basic setup
<?php
$args = array( \'orderby\' => \'nicename\' );
$users = get_users( $args );
foreach ( $users as $user ) {
$avatar = get_avatar( $user->ID, \'80\' );
echo \'<li><a href="\' .
$user->user_url .
\'">\' .
$avatar . \'<br />\' .
$user->display_name .
\'</a></li>\';
}
?>
Excluding the Admin User
要么签入
foreach
:
foreach ( $users as $user ) {
if( ! in_array( \'administrator\', $user->roles ) ) {
// echo user list
}
}
或者,如果所有其他用户都是订阅者,则包括
role
参数作为用户查询的参数:
$args = array(
\'orderby\' => \'nicename\',
\'role\' => \'subscriber\'
);
或者,如果您只有一个(或几个静态)管理员用户,请按id将其从查询中排除:
$args = array(
\'orderby\' => \'nicename\',
\'exclude\' => array( 1, 23 ) //adjust
);