WordPress.org

Ready to get started?Download WordPress

Forums

Problem with Coauthors (32 posts)

  1. laureninspace
    Member
    Posted 2 years ago #

    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?

  2. Daniel Bachhuber
    Hand Built
    Posted 2 years ago #

    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?

  3. laureninspace
    Member
    Posted 2 years ago #

    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.

  4. Daniel Bachhuber
    Hand Built
    Posted 2 years ago #

    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?

  5. laureninspace
    Member
    Posted 2 years ago #

    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.

  6. laureninspace
    Member
    Posted 2 years ago #

    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!

  7. Daniel Bachhuber
    Hand Built
    Posted 2 years ago #

    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?

  8. laureninspace
    Member
    Posted 2 years ago #

    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>
  9. Daniel Bachhuber
    Hand Built
    Posted 2 years ago #

    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; ?>
  10. laureninspace
    Member
    Posted 2 years ago #

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

  11. Daniel Bachhuber
    Hand Built
    Posted 2 years ago #

    It's actually built into Co-Authors Plus :) Just requires reading the documentation and code.

  12. laureninspace
    Member
    Posted 2 years ago #

    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.

  13. Daniel Bachhuber
    Hand Built
    Posted 2 years ago #

    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.

  14. marcqs
    Member
    Posted 2 years ago #

    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.

  15. Daniel Bachhuber
    Hand Built
    Posted 2 years ago #

    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?

  16. marcqs
    Member
    Posted 2 years ago #

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

  17. Daniel Bachhuber
    Hand Built
    Posted 2 years ago #

    You're welcome :)

  18. shawn00m
    Member
    Posted 2 years ago #

    OK, maybe I'm stupid or something, but I can't get the multiple authors to show up at all. I'm on WP 3.3.1 and I don't see any code like you're talking about. The instructions say to replace any code like this:
    <?php the_author(); ?>

    But, when I search for that, the closest I get is this:

    if ( ! function_exists( 'twentyeleven_posted_on' ) ) :
    /**
     * Prints HTML with meta information for the current post-date/time and author.
     * Create your own twentyeleven_posted_on to override in a child theme
     *
     * @since Twenty Eleven 1.0
     */
    function twentyeleven_posted_on() {
    	printf( __( '<span class="sep">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span></span>', 'twentyeleven' ),
    		esc_url( get_permalink() ),
    		esc_attr( get_the_time() ),
    		esc_attr( get_the_date( 'c' ) ),
    		esc_html( get_the_date() ),
    		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    		esc_attr( sprintf( __( 'View all posts by %s', 'twentyeleven' ), get_the_author() ) ),
    		get_the_author()
    	);
    }
    endif;

    When I try to work in the Co-Author code here the whole page blows up. Any help?

  19. marcqs
    Member
    Posted 2 years ago #

    Take a look at this thread, because a had the same question.

  20. Daniel Bachhuber
    Hand Built
    Posted 2 years ago #

  21. andyildefonso
    Member
    Posted 2 years ago #

    Is there someone who can help me out regarding this problem:

    I used the co-author plug-in for this article and manage to setup the authors info below the article. Here's the link:
    http://www.asiapathways-adbi.org/2012/03/reforming-asias-trade-in-services-will-help-human-development/

    But, when you click the archive link of the author, it display also the co-author bio instead of only one bio.

    See below the code. Any help is deeply appreciated.

    <?php
    		}
    	}
    }
    
    /*-----------------------------------------------------------------------------------*/
    /* Author Box */
    /*-----------------------------------------------------------------------------------*/
    
    if ( ! function_exists( 'woo_author' ) ) {
    	function woo_author() {
    		// Author box single post page
    		if ( is_single() && get_option( 'woo_disable_post_author' ) != 'true' )
    			add_action( 'woo_post_inside_after', 'woo_author_box', 10 );
    		// Author box author page
    		elseif ( is_author() )
    			add_action( 'woo_loop_before', 'woo_author_box', 10 );
    	}
    }
    
    /*-----------------------------------------------------------------------------------*/
    /* Single Post Author */
    /*-----------------------------------------------------------------------------------*/
    if ( ! function_exists( 'woo_author_box' ) ) {
    
    	function woo_author_box() {
    		global $post;
    		$author_id=$post->post_author;
    	?>
    
    	<?php
    		$i = new CoAuthorsIterator();
    		while($i->iterate()){
    	?>
    
    	<div id="post-author">
    	<div class="profile-image">
    		<?php echo get_avatar( get_the_author_meta('ID'), '80' ); ?>
    	</div>
    
    	<div class="profile-content">
    		<h4>
    		<?php printf( esc_attr__( 'About %s', 'woothemes' ), get_the_author('description', $author_id) ); ?></h4>
    		<?php echo get_the_author_meta( 'description'); ?>
    
    		<?php if (is_singular()) : ?>
    
    		<div class="profile-link">
    			<a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>">
    				<?php printf( __( 'View all posts by %s <span class="meta-nav">→</span>', 'woothemes' ), get_the_author( 'display_name', $author_id ) ); ?>
    			</a>
    		</div><!-- #profile-link -->
    		<?php endif; ?>
    
    	</div>
    	<div class="fix"></div>
    	</div>
    
    	<?php } ?>
    
    <?php
    	}
    }

    http://wordpress.org/extend/plugins/co-authors-plus/

  22. tulasiraman
    Member
    Posted 2 years ago #

    Hi,

    My problem is as that of shawn00m...

    I am able to select multiple authors while creating a post...
    But it does not show when the post is displayed in the site...

    In co-author plugin documentation it says to replace
    "the_author*()" with this
    "if(function_exists('coauthors_posts_links'))
    coauthors_posts_links();
    else
    the_author_posts_link();
    "

    The problem i dunno where i am supposed to find the
    "the_author*()"

    Any help would be appreciated,
    and Thank You...

  23. Daniel Bachhuber
    Hand Built
    Posted 2 years ago #

    Which theme are you using? Can you paste the contents of single.php into a pastebin and share it here?

  24. tulasiraman
    Member
    Posted 2 years ago #

    Thank you for getting back...

    The theme i am using is "Twenty Eleven"

    Contents of single.php

    [ Code moderated. For more than 10 lines of code please use pastebin.com instead. ]

    Kindly have a look at it...

  25. tulasiraman
    Member
    Posted 2 years ago #

    Thank you for getting back...

    The theme i am using is "Twenty Eleven"

    Contents of single.php

    <script src="http://pastebin.com/embed_js.php?i=DhdziUNS"></script>

    Kindly have a look at it...

  26. tulasiraman
    Member
    Posted 2 years ago #


  27. tulasiraman
    Member
    Posted 2 years ago #

    Hi,

    My Problem is...

    Have installed the co-author plus plugin...
    Can add multiple users to my post...

    But the co-authors are not seen in the post when viewed from the site front end...

    The documentation says to look for <?php the_author();
    I did not find this any where in the editor...

    The theme I am using is Twenty Ten. This came with wordpress itself.

    This is what is seen in single.php

    <?php get_header(); ?>
    <div id="container">
    <div id="content" role="main">
    <?php get_template_part( 'loop', 'single' );?>
    </div><!-- #content -->
    </div><!-- #container -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Please can help me with this...

  28. Daniel Bachhuber
    Hand Built
    Posted 2 years ago #

    You'll want to look at your theme's functions.php instead.

    Alternatively, you can replace uses of the twentyeleven_posted_on() function with your own code that displays the publication date, co-authors information, etc.

  29. tulasiraman
    Member
    Posted 2 years ago #

    Hi Daniel,

    Thanks for the suggestion. I have changed the theme to twentyeleven...

    In functions.php i have found this code

    if ( ! function_exists( 'twentyeleven_posted_on' ) ) :

    function twentyeleven_posted_on() {
    printf( __( '<span class="sep">Posted on </span><time class="entry-date" datetime="%3$s" pubdate>%4$s</time><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"></span></span>', 'twentyeleven' ),
    esc_url( get_permalink() ),
    esc_attr( get_the_time() ),
    esc_attr( get_the_date( 'c' ) ),
    esc_html( get_the_date() ),
    esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    esc_attr( sprintf( __( 'View all posts by %s', 'twentyeleven' ), get_the_author() ) ),
    get_the_author()
    );
    }
    endif;

    Now what changes should i make to this code...
    Sorry i have zero knowledge about php...

    Thanks in advance...

  30. inge12
    Member
    Posted 2 years ago #

    Hello Daniel,

    I use the Weaver ii Pro theme, and I posted on their forum re this plugin which would be very handy for me. I figured a child theme would be the perfect place to put the code to make the plugin functional. And it is -- because any other modifications would be lost in the next theme upgrade.

    (I like the theme because it is highly customizable, flexible and mobile-friendly, even without specific mobile modifications.)

    This is what the theme author, Bruce Weaver, replied:

    Well, I need to preach a bit here.

    1. That approach is entirely unnecessary. The plugin should be written to use a filter for 'the_author'. That is how WordPress is supposed to work.

    2. The replacement example will soon not work. The function 'the_author()' is deprecated - it will likely go away from WP soon. There is a replacement, 'get_the_author()', and that replacement will run the final output through the 'the_author' filter, where a plugin should be able to replace things.

    I wonder whether you could do a little more work on the plugin to make it more stable through WP upgrades and theme upgrades.

    Bruce provided a hint for stability through WP upgrades, and a child theme would make the plugin survive theme upgrades.

    Not everyone who might want to use the plugin is familiar with child themes. Thus a sample child theme including only the necessary modifications for this plugin would be very helpful. I might have posted the instructions, except that, if the plugin uses deprecated functions, its usefulness is rather short-term.

    Looking forward to your thoughts on this.

    Inge

Topic Closed

This topic has been closed to new replies.

About this Topic