Editing Theme to apply Co-Authors Plus

I’m trying to implement the Co-Authors Plus Plugin. It says that you will need to change some PHP in the theme. The documentation outlines the changes.

I believe I have found where I would need to change it in my theme. In the post-author-info.php file:

Read More
<?php
/**
 * Post Author Info
 *
 * @package WP Journal
 * @subpackage Include
 */
 ?>

<div id="authorinfo" class="columns alpha omega marT30 marB20">
    <a href="<?php the_author_meta('url'); ?>"><?php echo get_avatar( get_the_author_meta('email'), '80' ); ?></a>
    <h5 class="marB10"><?php _e('By', 'contempo'); ?>: <a href="<?php the_author_meta('url'); ?>"><?php the_author(); ?></a></h5>
    <p><?php the_author_meta('description'); ?></p>
        <div class="clear"></div>
</div>

Just adding this line:

<?php if ( function_exists( 'coauthors' ) ) { coauthors(); } else { the_author(); } ?>

…seems to give me something that I want. Both “Admin” And “Andrew Gable” are displayed.

But, I’m unsure on how to get it to link correctly, and how to handle photos and multiple Bio’s.

Related posts

Leave a Reply

2 comments

  1. I think you’re looking for something like this article. It’s rather comprehensive, but I’ll just cover the multiple BIOs and avatars. You’ll want to change your HTML code to this instead:

    <?php $i = new CoAuthorsIterator(); ?>
    <?php while( $i->iterate() ) : ?>
    <div id="authorinfo" class="columns alpha omega marT30 marB20">
        <a href="<?php the_author_meta('url'); ?>"><?php echo get_avatar( get_the_author_meta('email'), '80' ); ?></a>
        <h5 class="marB10"><?php _e('By', 'contempo'); ?>: <a href="<?php the_author_meta('url'); ?>"><?php the_author(); ?></a></h5>
        <p><?php the_author_meta('description'); ?></p>
            <div class="clear"></div>
    </div>
    <?php endwhile; ?>
    

    Here we interate through the different authors and display an avatar and BIO section for each one. Any content you add between the while and endwhile statements will be displayed once for each author.

    You also may want to replace where it says By Andrew Gable in the grey bar above the author box (in your template it probably looks like <?php the_author_posts_link() ?>) with <?php coauthors_posts_links(); ?>.

  2. Duplicate since it is also asked at: https://stackoverflow.com/questions/15119535/editing-theme-to-apply-co-authors-plus/19566948

    I had a similar issue and resolved it this way:

    global $post;
    $author_id=$post->post_author;
    foreach( get_coauthors() as $coauthor ): ?>
      <div class="entry-author co-author">
        <?php echo get_avatar( $coauthor->user_email, '96' ); ?>
        <h3 class="author vcard"><span class="fn"><a href="<?php echo get_author_posts_url( $coauthor->ID, $coauthor->user_nicename ); ?>"><?php echo $coauthor->display_name; ?></a></span></h3>
        <p class="author-bio"><?php echo $coauthor->description; ?></p>
        <div class="clear"></div>
       </div><!-- .entry-author co-author -->
    <?php endforeach;
    

    Be sure to use that global $post;and the foreach-loop.

    This function will display an author box containing author image/avatar, author name with link to its archive, and the author’s bio. You might want to use your own theme’s CSS classes though.

    The URL bungeshea posted was helpful.