我正在尝试输出具有贡献者角色的用户列表,以便可以在页面上显示所有贡献者及其某些属性(姓名,公司,职务,个人简介,照片等)
我的主题具有以下功能:
function my_text_after_content() {
if(is_page(400)) {
wp_list_authors( array(
'show_fullname' => 1,
'optioncount' => 1,
'orderby' => 'post_count',
'order' => 'DESC',
'html' => 0
) );
} };
这列出了我主题中的所有作者,但我很难将其限制为作者。关于如何最好地做到这一点并能够调用其其他参数的任何建议都将有所帮助。
答案 0 :(得分:0)
您需要首先获取非贡献者列表,然后从列表中排除其ID
$users = get_users(['role__not_in' => ['Contributor']]);
foreach( $users as $user ){
$ids[] = $user->ID;
}
if(is_page(400)) {
wp_list_authors( array(
'show_fullname' => 1,
'optioncount' => 1,
'orderby' => 'post_count',
'order' => 'DESC',
'html' => 0,
'exclude' => $ids
) );
} };
这两种方法也必须工作
$users = get_users(['role__in' => ['Contributor']]);
foreach( $users as $user ){
$ids[] = $user->ID;
}
if(is_page(400)) {
wp_list_authors( array(
'show_fullname' => 1,
'optioncount' => 1,
'orderby' => 'post_count',
'order' => 'DESC',
'html' => 0,
'include' => $ids
) );
} };