get ONLY authors for wordpress blog
I am trying to somehow get all of the authors for a wordpress blog, not the users. When i used wp_list_authors() it times out because there are over 50,000 users normally. How can i go about ONLY getting authors 开发者_如何转开发who publish data on the blog?
In the options array you pass to the wp_list_authors()
function, you need to set hide_empty
to true
. This will exclude all authors with 0 posts.
See the function reference.
Example:
<?php
wp_list_authors(array('hide_empty' => true));
?>
There are a few points to be made here to address your problem. Only users with the title of 'author' and above can author a post on a wordpress site. If you examine the wordpress documentation for the wp_list_authors() function you will learn that the hide_empty parameter has a default of 1(true) so it is not nessicary to declare it in the function call. I setup a test on my local server and found that the function works in all of the following ways as predicted in the documentation.
<?php
wp_list_authors('hide_empty=1'); //wordpress example
wp_list_authors(array('hide_empty' => true)); //Alex
wp_list_authors(); //Best
?>
All of which will only show authors that have contributed a minimum of one post in a list format. Are there any additional details you may have left out?
精彩评论