WordPress.org

Support

Support » Plugins and Hacks » Problem with Coauthors

Problem with Coauthors

Viewing 15 replies - 1 through 15 (of 31 total)
  • Daniel Bachhuber
    Participant

    @danielbachhuber

    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?

    laureninspace
    Member

    @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.

    Daniel Bachhuber
    Participant

    @danielbachhuber

    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?

    laureninspace
    Member

    @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.

    laureninspace
    Member

    @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!

    Daniel Bachhuber
    Participant

    @danielbachhuber

    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?

    laureninspace
    Member

    @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>
    Daniel Bachhuber
    Participant

    @danielbachhuber

    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; ?>
    laureninspace
    Member

    @laureninspace

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

    Daniel Bachhuber
    Participant

    @danielbachhuber

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

    laureninspace
    Member

    @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.

    Daniel Bachhuber
    Participant

    @danielbachhuber

    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.

    Daniel Bachhuber
    Participant

    @danielbachhuber

    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.