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:

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

<div id="authorinfo" class="columns alpha omega marT30 marB20">
    <a href="https://wordpress.stackexchange.com/questions/88548/<?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="https://wordpress.stackexchange.com/questions/88548/<?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.

2 Answers
2

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="https://wordpress.stackexchange.com/questions/88548/<?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="https://wordpress.stackexchange.com/questions/88548/<?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(); ?>.

Leave a Comment