admin管理员组文章数量:1026989
I am using wp_list_authors, to, how function name says, make a list of authors, but i want to show only "Authors". Now in my site, any account who publish a text ("Admin", "Editor") show his name in my list of authors, but i want ONLY users who are Authors. How can i make this happen?
My code now
<?php $args = array(
'orderby' => 'name',
'order' => 'ASC',
'number' => 6,
'optioncount' => true,
'exclude_admin' => true,
'show_fullname' => false,
'hide_empty' => true,
'echo' => true,
'style' => 'list',
'html' => true); ?>
I am using wp_list_authors, to, how function name says, make a list of authors, but i want to show only "Authors". Now in my site, any account who publish a text ("Admin", "Editor") show his name in my list of authors, but i want ONLY users who are Authors. How can i make this happen?
My code now
<?php $args = array(
'orderby' => 'name',
'order' => 'ASC',
'number' => 6,
'optioncount' => true,
'exclude_admin' => true,
'show_fullname' => false,
'hide_empty' => true,
'echo' => true,
'style' => 'list',
'html' => true); ?>
Share
Improve this question
asked Mar 25, 2019 at 17:33
Matheus RibeiroMatheus Ribeiro
11 bronze badge
1
|
1 Answer
Reset to default 1wp_list_authors(), displays a list of the sites's authors (users), and if the user has authored any posts, the author name is displayed as a link to their posts.
Use
$authors = get_users( [ 'role__in' => [ 'auther'] ],
// add other parameters
);
Then loop through $authors to create your own list.
foreach ( $authors as $author ) {
// your list goes here
}
I hope this helps to start.
I am using wp_list_authors, to, how function name says, make a list of authors, but i want to show only "Authors". Now in my site, any account who publish a text ("Admin", "Editor") show his name in my list of authors, but i want ONLY users who are Authors. How can i make this happen?
My code now
<?php $args = array(
'orderby' => 'name',
'order' => 'ASC',
'number' => 6,
'optioncount' => true,
'exclude_admin' => true,
'show_fullname' => false,
'hide_empty' => true,
'echo' => true,
'style' => 'list',
'html' => true); ?>
I am using wp_list_authors, to, how function name says, make a list of authors, but i want to show only "Authors". Now in my site, any account who publish a text ("Admin", "Editor") show his name in my list of authors, but i want ONLY users who are Authors. How can i make this happen?
My code now
<?php $args = array(
'orderby' => 'name',
'order' => 'ASC',
'number' => 6,
'optioncount' => true,
'exclude_admin' => true,
'show_fullname' => false,
'hide_empty' => true,
'echo' => true,
'style' => 'list',
'html' => true); ?>
Share
Improve this question
asked Mar 25, 2019 at 17:33
Matheus RibeiroMatheus Ribeiro
11 bronze badge
1
-
At first glance it looks like your best bet is to fetch a list of all editors by role and then pass their IDs into your $args as 'exclude'. I don't think there's any way to hook
'role__not_in' => [ 'editor' ]
into the get_users call it makes because the args get passed through wp_array_slice_assoc. So this isn't great: it might be worth making your own version of wp_list_authors you can customise, or caching some or all of this in transients if you call it a lot I suppose. – Rup Commented Mar 25, 2019 at 18:07
1 Answer
Reset to default 1wp_list_authors(), displays a list of the sites's authors (users), and if the user has authored any posts, the author name is displayed as a link to their posts.
Use
$authors = get_users( [ 'role__in' => [ 'auther'] ],
// add other parameters
);
Then loop through $authors to create your own list.
foreach ( $authors as $author ) {
// your list goes here
}
I hope this helps to start.
本文标签: functionsFilter to wplistauthors
版权声明:本文标题:functions - Filter to wp_list_authors 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745660092a2161836.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
'role__not_in' => [ 'editor' ]
into the get_users call it makes because the args get passed through wp_array_slice_assoc. So this isn't great: it might be worth making your own version of wp_list_authors you can customise, or caching some or all of this in transients if you call it a lot I suppose. – Rup Commented Mar 25, 2019 at 18:07