New template tags enable listing of co-authors:
coauthors()coauthors_posts_links()coauthors_firstnames()coauthors_lastnames()coauthors_nicknames()coauthors_links()coauthors_IDs()These template tags correspond to their "the_author*" equivalents; take special note of the pluralization.
Each of these template tags accept four optional arguments:
between: default ", "betweenLast: default " and "before: default ""after: default ""To use them, simply modify the code surrounding all instances of the_author*() to something like the following example:
if(function_exists('coauthors_posts_links'))
coauthors_posts_links();
else
the_author_posts_link();
The result of this would be formatted like "John Smith, Jane Doe and Joe Public".
Note that as of this writing, WordPress does provide a means of extending wp_list_authors(), so
included in this plugin is the function coauthors_wp_list_authors() modified
to take into account co-authored posts; the same arguments are accepted.
Sometimes you may need fine-grained control over the display of a posts's authors, and in this case you may use
the CoAuthorsIterator class. This class may be instantiated anywhere you may place the_author()
or everywhere if the post ID is provided to the constructor. The instantiated class has the following methods:
iterate(): advances $authordata to the next co-author; returns false and restores the original $authordata if there are no more authors to iterate. get_position(): returns the zero-based index of the current author; returns -1 if the iterator is invalid.is_last(): returns true if the current author is the last.is_first(): returns true if the current author is the first.count(): returns the total number of authors.get_all(): returns an array of all of the authors' user data.For example:
$i = new CoAuthorsIterator();
print $i->count() == 1 ? 'Author: ' : 'Authors: ';
$i->iterate();
the_author();
while($i->iterate()){
print $i->is_last() ? ' and ' : ', ';
the_author();
}
get_the_coauthor_meta( $field ) (2.8 only)the_coauthor_meta( $field ) (2.8 only)Note: The $field variable corresponds with the same values accepted by the the author meta function.
get_coauthors( [$post_id], [$args] )This function returns an array of coauthors for the specified post, or if used inside the Loop, the current post active in the Loop. the $args paramater is an array that allows you to specify the order in which the authors should be returned.
is_coauthor_for_post( $user, $post_id )This function allows you to check whether the specified user is coauthor for a post. The $user attribute can be the user ID or username.




