Support » Fixing WordPress » [Plugin: Co-Authors Plus] Displaying Multiple Authors?

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Anyone? Thanks in advance!

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

    pints1ze

    (@pints1ze)

    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');

    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 🙂

    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!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Co-Authors Plus] Displaying Multiple Authors?’ is closed to new replies.