Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to show co-authors when using the Hybrid theme
<?php
add_filter( 'hybrid_byline', 'my_byline' );
function my_byline( $byline ) {
global $post;
if ( 'post' == $post->post_type ) {
$authors_list = '';
if(function_exists('get_coauthors')) {
$coauthors = get_coauthors();
$count = 0;
foreach( $coauthors as $coauthor ) {
if( $count > 0 ) {
if( $count < count($coauthors) - 1 ) {
$authors_list .= ', ';
} else if ( $count >= count($coauthors) - 1 ) {
$authors_list .= __(' and ');
}
}
$authors_list .= get_author_posts_url($coauthor->ID);
$count++;
}
} else {
$authors_list .= get_author_posts_url(get_the_author()->ID);
}
return '<p class="byline">By '. $authors_list .' on [entry-published] [entry-edit-link before=" | "]</p>';
}
return $byline;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment