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.

/**
 * 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' );

Author: Daniel Bachhuber

Proud father x2. Principal, Hand Built. Maintainer, WP-CLI.

5 thoughts on “Co-authors in your RSS feeds”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s