扩展Raja的答案,您还可以编写一个助手函数来为您处理此问题:
<?php
# This goes in functions.php
function get_users_by_role($role, $orderby, $order) {
$args = array(
\'role\' => $role,
\'orderby\' => $orderby,
\'order\' => $order
);
$users = get_users( $args );
return $users;
}
?>
然后,要通过特定角色获取用户,您只需执行以下操作:
<?php $users = get_users_by_role(\'Your role\', \'user_nicename\', \'ASC\'); ?>