WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Co-Authors Plus] Displaying Multiple Authors? (6 posts)

  1. pac10dave
    Member
    Posted 5 years ago #

    Even if I add another author, the post still displays as:

    TITLE
    by Author 1

    And Author 2 appears to be hidden. On posts that I collaborate with another Author, I'd like it to read:

    TITLE
    by Author 1 and Author 2

    Is this possible? I'm code illiterate so please be as detailed as possible. Thank you!!

  2. pac10dave
    Member
    Posted 5 years ago #

    Anyone? Thanks in advance!

  3. Mohammad Jangda
    Member
    Posted 5 years ago #

    Did you add the coauthor() tag to your template files? For example, you need to replace the the_author(); with coauthors();

  4. pints1ze
    Member
    Posted 4 years ago #

    I just recently ran into this problem, but didn't want to find every occurance of the_author() in my theme. I put together a filter that hooks into the_author() in my themes functions.php file that did the trick... It could probably be cleaned up quite a bit, but hopefully it helps:

    function use_coauthors() {
    	$authors = get_coauthors();
    	$numauthors = count($authors);
    	$result = '';
    	foreach($authors as $author){
    		$result .= $author->display_name;
    		if ($numauthors > 2) {
    			$result .= ', ';
    		} elseif ($numauthors == 2) {
    			$result .= ' and ';
    		} else {
    			$result .= '';
    		}
    		$numauthors--;
    	}
    	return $result;
    }
    if ( function_exists('get_coauthors') )
    	add_filter('the_author','use_coauthors');
  5. Mohammad Jangda
    Member
    Posted 4 years ago #

    pints1ze: that is awesome!

    I didn't know there was a filter for the_author! Would you mind if I add your code into the plugin? I'll credit you of course :)

  6. ebhpf
    Member
    Posted 4 years ago #

    Hi! First off thanks for enhancing this plugin it sounds like I am needing however I am having troubles implementing the plugin with my K2 theme template. I have added the above code:

    function use_coauthors() {
    $authors = get_coauthors();
    $numauthors = count($authors);
    $result = '';
    foreach($authors as $author){
    $result .= $author->display_name;
    if ($numauthors > 2) {
    $result .= ', ';
    } elseif ($numauthors == 2) {
    $result .= ' and ';
    } else {
    $result .= '';
    }
    $numauthors--;
    }
    return $result;
    }
    if ( function_exists('get_coauthors') )
    add_filter('the_author','use_coauthors');

    and also replaced all my the_author with coauthors, yet it still does not seem to appear on my blog.

    Any help would be greatly appreciated.

    Thanks so much in advance!

Topic Closed

This topic has been closed to new replies.

About this Topic