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]

7 Comments

razorfrog December 13, 2011 Reply

Simple enough – thank you!
-razorfrog, not razorfish 🙂

Daniel Bachhuber December 13, 2011 Reply

D’oh, sorry about that. Fixed 🙂 I have a bit of a fever and promise this is the most complex code I’ve written all day.

Gary O February 4, 2013 Reply

thanks for the fix — this did the trick!

fidelduque January 25, 2016 Reply

Thank you very much! it worked like a charm!

Matt October 25, 2021 Reply

This is ancient at this point, but is this still the right approach for this? I haven’t dug very far into it, but I’m not seeing the change in my RSS feeds after adding the snippet.

Daniel Bachhuber October 25, 2021 Reply

Should work just fine! Not much about the underlying code has changed in the last decade 🙂

Make sure your feed cache is flushed. Feeds can get cached pretty aggressively, so that could be why it’s not showing up.

Leave a Reply