Automattic / Co-Authors-Plus

Multiple bylines and Guest Authors for WordPress
https://wordpress.org/plugins/co-authors-plus/
GNU General Public License v2.0
290 stars 205 forks source link

Only one co-author showing when editor role #922

Open MrBryan opened 1 year ago

MrBryan commented 1 year ago

I posted this on your wordpress plugin page but haven't heard anything so i'll share here:

https://wordpress.org/support/topic/only-one-co-author-showing-when-editor-role/

we have co-authors plus and when a post has multiple authors, it will show in most cases. However, when both, or more than one of the authors has an ‘editor’ role, only one of those with the role will display on the article (because your function is only returning one of them)

We are using a theme based on newspack and I’ve looked at the code where authors are being parsed in inc/template-tags.php and it appears to correctly use the plugin functions :

<span class="byline">
<span><?php echo esc_html__( 'by', 'newspack' ); ?></span>
<?php
foreach ( $authors as $author ) {
$i++;
if ( $author_count === $i ) 
/* translators: separates last two names; needs a space on either side. */
$sep = esc_html__( ' and ', 'newspack' );
elseif ( $author_count > $i ) 
/* translators: separates all but the last two names; needs a space at the end. */
$sep = esc_html__( ', ', 'newspack' );
else :
$sep = '';
endif;
printf(
/* translators: 1: author link. 2: author name. 3. variable seperator (comma, 'and', or empty) */
'<span class="author vcard"><a class="url fn n" href="%1$s">%2$s</a></span>%3$s ',
esc_url( get_author_posts_url( $author->ID, $author->user_nicename ) ),
esc_html( $author->display_name ),
esc_html( $sep )
);
}
?>
</span><!-- .byline -->