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
  • 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
Add a comment  | 

1 Answer 1

Reset to default 1

wp_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
Add a comment  | 

1 Answer 1

Reset to default 1

wp_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