0

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); ?>
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 1

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.

2
  • Oh, thank you, this worked how i wanted! Thanks :) Commented Mar 25, 2019 at 18:42
  • Stay blessed! always. Commented Mar 25, 2019 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.