David Stockdale's Scrapcode

Embed Customisation Supporting “Co-Authors Plus” (With Archive Links)

More fiddling with embedded posts, this time making changes to the code outlined in Embed Customisation Supporting “Co-Authors Plus” in order to make every authors name into a link to their post archive page.

/**
 * Removes the title (David Stockdale).
 */
add_filter('embed_site_title_html','__return_false');
/**
 * Adds the author's names (David Stockdale).
 */
add_action( 'embed_content', 'embed_author' );
/**
 * Adds the author div to the embed iframe (David Stockdale).
 */
function embed_author() {
    $output = '<div class="wp-embed-author"><ul>';
	$coauthors = get_coauthors();
	foreach( $coauthors as $coauthor ): 
		$output .= '<li>';
		$authorArchiveLink = get_author_posts_url($coauthor->ID);
		$output .=  "<a href=$authorArchiveLink> $coauthor->user_firstname $coauthor->user_lastname</a>";
		$output .= " ";
		$output .= get_avatar( get_userdata( $coauthor->ID ), 20 );
		$output .= '</li>';
	endforeach;
	$output .= '</ul></div>';
    echo $output;
}

Leave a Reply