How to replace default WP author with custom field in RSS feed

Simply add this snippet into functions.php code.


function feed_author() {
    if( is_feed() ) {
        global $post;
        
		$author = get_the_terms($post->ID,'authors');
		$num_of_items = count($author);
  		$num_count = 0;
		
		if ( $author ) {
			foreach($author as $aut) {
				$name .= $aut->name;
				
				$num_count++;
				if ($num_count < $num_of_items) {
				  $name .= ", ";
				}
			}
		}
		
        return $name; 
    }
}

add_filter( 'the_author', 'feed_author' );

Leave a Reply

Your email address will not be published.