Show biographies for co-authors at the end of your post

In the 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.

 * 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-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>';

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.

Author: Daniel Bachhuber

Proud father x2. Principal, Hand Built. Maintainer, WP-CLI.

4 thoughts on “Show biographies for co-authors at the end of your post”

  1. Daniel,

    What’s a simple way to check in php if there is more than one author?

    For example, I’d like to replace my author avatar at the top of a post with just the blog logo in cases were there are multiple authors (using co-authors plus, of course), and I’d like to remove/replace the custom author box at the bottom of a post for these types as well. So I just need a quick if-then statement, but I’m not yet familiar with the plugin, hoping it’s something easy you can give me :). If number of authors is greater than one…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s