I’m trying to build an author list that would show all authors that have written a Custom Post Type post, and hide authors that have no posts. With wp_list_authors
it would be easy to show users that have written Posts (not CPT).
This does not show the users that have published Custom Post Types, it affects only to Posts.
wp_list_authors('hide_empty=1');
I looked in to the get_users
function but managed to only build a list with it (more control over the list but not what I was aiming for).
$blog_url = get_bloginfo('home');
$blogusers = get_users('orderby=display_name&role=editor');
foreach ($blogusers as $user) {
echo '<li><a href="' . $blog_url . '/author/' . $user->user_login . '">' . $user->display_name . '</a></li>';
}
I found this really nice post dealing with how to show the post counts in the backend. It defines a function _yoursite_get_author_post_type_counts()
that could possibly maybe be some help in this…
Any idea how to do this? Thanks! 🙂
wp_list_authors()
, internally gets posts that are only of typepost
. See line 294 http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/author-template.php#L273As you have noted, this answer is great and with some modification can do what you want.
You already know how to
get_users
, so it should be a piece of cake to setup a simpleforeach
loop and feed the user IDs into your new function.I’ve tested the function to some extent, it should work as is, but may require some tweaking. Let me know if you have any questions and/or how I can improve my answer.