In the WordPress.org forums, doubleedesign says:
I want to add the authors’ biographies to the end of each post.
Awesome… it’s pretty simple to do. Conceptually, what we need to do is load our co-authors, and then loop through printing the relevant information for each one.
You’ll want to put the following code snippet within The Loop in any template you’d like the bios to appear.
[sourcecode language=”php”]
/**
* Show multiple Co-Author biography fields at the bottom of a single post
* This snippet should be placed within The Loop
*/
if ( class_exists( ‘coauthors_plus’ ) ) {
// Get the Co-Authors for the post
$co_authors = get_coauthors();
// For each Co-Author, echo a wrapper div, their name, and their bio if they have one
foreach ( $co_authors as $key => $co_author ) {
$co_author_classes = array(
‘co-author-wrap’,
‘co-author-number-‘ . ( $key + 1 ),
);
echo ‘<div class="’ . implode( ‘ ‘, $co_author_classes ) . ‘">’;
echo ‘<h4 class="co-author-display-name">’ . $co_author->display_name . ‘</h4>’;
// Only print the description if the description exists
if ( $description = get_the_author_meta( ‘description’, $co_author->ID ) )
echo ‘<p class="co-author-bio">’ . $description . ‘</p>’;
echo ‘</div>’;
}
}
[/sourcecode]
If you’d like other co-author details to appear as well, like their avatar for instance, you can modify the output within the foreach loop.
Leave a Reply