Co-authors in your RSS feeds

In the WordPress.org forums, razorfrog asks:

Short of editing core WordPress code, is it possible to display the multiple authors in the site’s RSS feed?

Of course there is! From the source code, we know the RSS feed template uses the_author() to display the post’s byline information. Furthermore, the_author() echoes get_the_author() which is a filterable function. Filters allow us to programmatically change values used in a function. What we need to do is write a short snippet to produce the co-authors byline when an RSS feed is requested and Co-Authors Plus is activated.

The snippet is as follows, and can be placed in your theme’s functions.php file or a standalone MU plugin.

[sourcecode lang=”php”]/**
* Co-authors in RSS and other feeds
* /wp-includes/feed-rss2.php uses the_author(), so we selectively filter the_author value
*/
function db_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’, ‘db_coauthors_in_rss’ );[/sourcecode]

4 thoughts on “Co-authors in your RSS feeds

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>