Skip to content

Instantly share code, notes, and snippets.

@joshuadavidnelson
Created March 16, 2012 21:57
Show Gist options
  • Save joshuadavidnelson/2053037 to your computer and use it in GitHub Desktop.
Save joshuadavidnelson/2053037 to your computer and use it in GitHub Desktop.
Displaying Co-Authors in Thesis Theme
<?php
/* ------ [ Display Post Avatars w/ Co-Author Alternate ] ------ */
function custom_author_post_avatar(){
if(is_home() || is_single()){
if ( function_exists( 'get_coauthors' ) && 1 == count( get_coauthors( get_the_id() ) ) ) {
if(get_query_var('author_name')){
$curauth = get_userdatabylogin(get_query_var('author_name'));
}else{
$curauth = get_userdata(get_query_var('author'));
}
?>
<div class="author_grav">
<a href="<?php echo get_bloginfo ( 'url' ); ?>/author/<?php echo get_the_author_meta( 'user_login' ); ?>"><?php get_avatar( get_the_author_email(), '50' ); ?></a>
</div>
<?php } else { ?>
<div class="author_grav">
<a href="<?php echo get_bloginfo ( 'url' ); ?>"><img src="LOGO" width="50" /></a>
</div>
<?php
}
}
}
add_action('thesis_hook_before_headline', 'custom_author_post_avatar');
?>
<?php
/* ------ [ Display Co-Authors in the Byline ] ------ */
function multi_authors() {
if( function_exists( 'get_coauthors' ) ) {
$i = new CoAuthorsIterator();
$return = '<p class="headline_meta">by <span class="author vcard">';
$i->iterate();
$return .= '<a href="'.get_author_posts_url(get_the_author_meta('ID')).'">'.get_the_author_meta('display_name').'</a>';
while($i->iterate()){
$return.= $i->is_last() ? ' and ' : ', ';
$return .= '<a href="'.get_author_posts_url(get_the_author_meta('ID')).'">'.get_the_author_meta('display_name').'</a>';
}
$return .= '</span> on <abbr class="published" title="'.get_the_time('jS F Y').'">'.get_the_time('jS F Y').'</abbr></p>';
echo $return;
} else { ?>
<p class="headline_meta">by <?php thesis_author(); ?></p>
<?php }
}
add_action('thesis_hook_after_headline', 'multi_authors');
?>
<?php
/* ----- [ Display Co-Authors In RSS ] ----- */
function coauthors_in_rss( $the_author ) {
if ( !is_feed() || !function_exists( 'coauthors' ) )
return $the_author;
return coauthors( null, null, null, null, false );
}
add_filter( 'the_author', 'coauthors_in_rss' );
?>
<?php
/* ----- [ Display Co-Authors in Teaser Byline ] ---- */
function multi_authors_teaser() {
if(function_exists( 'get_coauthors' )) {
$i = new CoAuthorsIterator();
$return = 'by <span class="teaser_author">';
$i->iterate();
$return .= '<a href="'.get_author_posts_url(get_the_author_meta('ID')).'">'.get_the_author_meta('display_name').'</a>';
while($i->iterate()){
$return.= $i->is_last() ? ' and ' : ', ';
$return .= '<a href="'.get_author_posts_url(get_the_author_meta('ID')).'">'.get_the_author_meta('display_name').'</a>';
}
$return .= '</span> on <abbr class="teaser_date published" title="'.get_the_time('jS F Y').'">'.get_the_time('jS F Y').'</abbr>';
} else {
$return = 'by <span class="teaser_author">';
$return .= '<a href="'.get_author_posts_url(get_the_author_meta('ID')).'">'.get_the_author_meta('display_name').'</a>';
$return .= '</span> on <abbr class="teaser_date published" title="'.get_the_time('jS F Y').'">'.get_the_time('jS F Y').'</abbr>';
}
echo $return;
}
add_action('thesis_hook_after_teaser_headline', 'multi_authors_teaser');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment