Support » Plugin: Co-Authors Plus » Multiple "About Author" Boxes.

Viewing 4 replies - 1 through 4 (of 4 total)
  • There is a lot of suggestions to paste code into a .php file, but I haven’t found which .php file to update. My theme doesn’t seem to have any of the suggested files.

    I’m stuck and would really like to get this resolved.

    intentionallywidenberg

    (@intentionallywidenberg)

    I’m using Mantra theme, and I did a search in the wp/wp-content/themes/mantra files for things like get_the_author and get_avatar.
    I found 2 major instances – the code to make byline at the top of a post and the code to make the bio at the bottom.

    for the bio, (in single.php) I rewrote the code to take an array of authors instead of a singular one, and loop through the array.
    I also added a snippet of code above it to check for coauthor plugin, and call it if present or wrap the get_the_author result with an array so it would work with my modified code.

    Obviously I wrapped the existing code in a loop, iterating through each coauthor to feed to the existing code.
    Then I had to figure out how to get the get_the_author’s_blahblahblah() functions to get the correct info for each coauthor rather than the default author. I found that most of the functions would take an optional ID argument, so I saved it as $user_id and added it to the function calls. I think I had to replace one function with an explicit call to look up the display_name or else I got the same name repeated.

    <?php
        // Safety first. Make sure code will work if coauthors plugin is off
        $authornum = 0;
        if ( function_exists( 'get_coauthors' ) ) {
    	$coauthors = get_coauthors();
        } else {
    	$coauthors = array();
    	$coauthors[] = get_the_author();
        } ?>
    <?php
        foreach( $coauthors as $coauthor ) {
    	$authornum = $authornum + 1;
    	$user_id = $coauthor->ID;
     ?>
    <?php if ( get_the_author_meta( 'description', $user_id ) ) : // If a user has filled out their description, show a bio on their entries  ?>
    					<div id="entry-author-info">
    						<div id="author-avatar">
    							<?php echo get_avatar( get_the_author_meta( 'user_email', $user_id ), apply_filters( 'mantra_author_bio_avatar_size', 60 ) ); ?>
    						</div><!-- #author-avatar -->
    						<div id="author-description">
    							<h2><?php printf( esc_attr__( 'About %s', 'mantra' ), get_the_author_meta( 'display_name', $user_id ) ); ?></h2>
    							<?php the_author_meta( 'description', $user_id ); ?>
    							<div id="author-link">
    								<a>">
    									<?php printf( __( 'View all posts by ','mantra').'%s <span class="meta-nav">→</span>', get_the_author_meta('display_name', $user_id) ); ?>
    								</a>
    							</div><!-- #author-link	-->
    						</div><!-- #author-description -->
    					</div><!-- #entry-author-info -->
    <?php endif;
    } ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been damaged by the forum’s parser.]

    Thanks intentionallywidenberg.

    I have been struggling with this for a while and you coding got me almost all the way. The only thing i need to get working now (except for some styling) is to make the h2 line into the link for the “author archive” (The page that shows all the posts from one author)

    I have tried with “coauthors_posts_links” but that lists both the authors in one line. You can se the test post here:

    http://rftest.mo-mo.dk/2015/07/noegne-tosser-og-badebolde-paa-afveje-vi-var-en-tur-paa-badesoeen/

    Can you help me with this? Its probably something simple, but its late and my head dont work anymore. :p

    <?php
        // Safety first. Make sure code will work if coauthors plugin is off
        $authornum = 0;
        if ( function_exists( 'get_coauthors' ) ) {
        $coauthors = get_coauthors();
        } else {
        $coauthors = array();
        $coauthors[] = get_the_author();
        } ?>
    <?php
        foreach( $coauthors as $coauthor ) {
        $authornum = $authornum + 1;
        $user_id = $coauthor->ID;
     ?>
    <?php if ( get_the_author_meta( 'description', $user_id ) ) : // If a user has filled out their description, show a bio on their entries  ?>
                        <div id="entry-author-info">
                            <div id="author-avatar">
                                <?php echo get_avatar( get_the_author_meta( 'user_email', $user_id ), apply_filters( 'mantra_author_bio_avatar_size', 200 ) ); ?>
                            </div><!-- #author-avatar -->
                            <div id="author-description">
                                <h2><?php printf( get_the_author_meta( 'display_name', $user_id ) ); ?></h2>
                                <?php the_author_meta( 'description', $user_id ); ?>
                                <div id="author-link">
                                <?php echo coauthors_posts_links(); ?>
                                </div><!-- #author-link -->
                            </div><!-- #author-description -->
                        </div><!-- #entry-author-info -->
    <?php endif;
    } ?>

    It looks like for me, I would need to update the author-template.php page. Do I need to update all functions that reference the_author and replace it with coauthor?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Multiple "About Author" Boxes.’ is closed to new replies.