• I am managing a site – http://teen.americanobserver.net — on the Morning After theme. It automatically displays an author bio on single.php after the post content. However, some of the articles have two authors, which I maintain with the Coauthors Plus plugin (and sometimes Double Bylines.) When I use these, only the first author on the post shows up — both for the byline and the bio.

    How can I get two author bios to show up when two authors are listed?

Viewing 15 replies - 1 through 15 (of 31 total)
  • Hey Lauren,
    Do you have access to edit the theme template? You’ll need to do so in order to add Co-Authors Plus support?

    Thread Starter laureninspace

    (@laureninspace)

    Hi Dan,

    I’ve got administrator status on the site, so yes, I can go into the Editor. I can also give other people admin status.

    In order to display information about multiple authors on the frontend, you’ll need to add the necessary Co-Authors Plus template tags to your single.php and other theme files.

    Specifically for the bylines, you’ll want to replace where it says something like:

    <?php the_author(); ?>

    With something like this:

    `<?php if ( function_exists( ‘coauthors’ ) ) { coauthors(); } else { the_author(); } ?>

    That specific snippet will allow your theme to degrade gracefully when Co-Authors Plus isn’t activated.

    Can you find and list the code you have for displaying author descriptions?

    Thread Starter laureninspace

    (@laureninspace)

    That worked! Now I am getting the authors. It’s odd that I’m getting it with a comma like this:

    By John Doe, and John Doe

    But yes, it’s working. Now all I need to do is put in a conditional for inserting two different bios.

    Thread Starter laureninspace

    (@laureninspace)

    I forgot about something crucial. When I took out the earlier code, I removed the link to the author’s page that lists every post that author has written.

    <?php the_author_posts_link(); ?>

    I can put this right back in for single authors, but I am unsure of how to make it work with two authors. Thanks!

    Regarding the comma, that sounds like a bug. Let’s see if we can get an updated version from @batmoo 🙂

    To show the authors with their posts link, you’ll want to use something like:

    <?php if ( function_exists( 'coauthors_posts_links' ) ) { coauthors_posts_links(); } else { the_author_posts_link(); } ?>

    Can you share the code you’re using for bios?

    Thread Starter laureninspace

    (@laureninspace)

    Sorry I didn’t respond more quickly — must have missed this email. However, that solution worked very well. Moving on to bios, this is what I’m using to make one bio show up:

    <center><div class="authbio">
    <img src="<?php bloginfo('template_url'); ?>/images/<?php the_author_firstname(); ?>.jpg" alt="" class="alignleft"/>
    <?php the_author_description(); ?>
    </div></center>

    Cool. You should be able to replace it with something like:

    <?php $coauthors = get_coauthors(); ?>
    <?php foreach( $coauthors as $coauthor ): ?>
    <center><div class="authbio">
    <img src="<?php bloginfo('template_url'); ?>/images/<?php echo $coauthor->user_firstname; ?>.jpg" alt="" class="alignleft"/>
    <?php $userdata = get_userdata( $coauthor->ID ); ?>
    <?php if ( $userdata->user_description ) echo $userdata->user_description; ?>
    </div></center>
    <?php endforeach; ?>
    Thread Starter laureninspace

    (@laureninspace)

    Perfect! Now all of my problems are resolved. Do you think this will ever be a part of the Coauthors Plus plugin?

    It’s actually built into Co-Authors Plus 🙂 Just requires reading the documentation and code.

    Thread Starter laureninspace

    (@laureninspace)

    You should have told me that sooner! Meeting you inspired me to learn a lot more about WordPress, and I probably could have handled it myself.

    Lauren, as a heads up, if you upgrade to the latest version of Co-Authors Plus it will get rid of your pesky comma problem.

    Hello. I would like put the link for each author’s archive after author’s bio in a similar way as does twenty eleven theme.

    Author 1
    Description
    View all posts by Author 1

    Author 2
    Description
    View all posts by Author 2

    For this I used a code similar to that showed by Daniel. I show the sample code that works fine so far (the modification is made ​​in content.single.php template):

    <div id="author-info">
    	<?php
    	$coauthors = get_coauthors(); ?>
    	<?php foreach( $coauthors as $coauthor ): ?>
    	<div class="author-description">
    	<?php $userdata = get_userdata( $coauthor->ID ); ?>
    		<h2><?php if ( $userdata->display_name ) echo $userdata->display_name; ?></h2>
    <		?php if ( $userdata->user_description ) echo $userdata->user_description; ?>
    </div>

    What I want to do now is put the link to the archive of each author. My question is: there is a better way to do this or how can this be done by adding something extra at the end of the code above? Thanks in advance for the help you can give me.

    Yep, you can add something like this:

    <a href="<?php echo get_author_posts_url( $coauthor->ID ); ?>">View all posts by <?php echo $coauthor->display_name; ?></a>

    right above the last <div>. Make sense?

    Totally. Works great. This helps me get a better understanding of the plugin to do other things. Thanks for your time and support.

Viewing 15 replies - 1 through 15 (of 31 total)
  • The topic ‘Problem with Coauthors’ is closed to new replies.