您可以使用以下选项:
// prepare arguments
$args = array(
// search only for Authors role
\'role\' => \'Author\',
// order results by display_name
\'orderby\' => \'display_name\'
);
// Create the WP_User_Query object
$wp_user_query = new WP_User_Query($args);
// Get the results
$authors = $wp_user_query->get_results();
// Check for results
if (!empty($authors))
{
echo \'<ul>\';
// loop trough each author
foreach ($authors as $author)
{
// get all the user\'s data
$author_info = get_userdata($author->ID);
echo \'<li>\'.$author->ID.\' \'.$author_info->first_name.\' \'.$author_info->last_name.\'</li>\';
}
echo \'</ul>\';
} else {
echo \'No authors found\';
}
有关更多参考,请参阅
this.