Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've seen that other sites have done this but didn't manage to do it myself.

I have certain custom fields for each post and I want one of these custom fields to be shown in the RSS feed in the title for each item after the item's actual title. For example, if the post is named "Abracadabra and hocus pocus" and is written by James A. Author I would like the feed item title to be "Abracadabra and hocus pocus by James A. Author".

How can this be done?

share|improve this question
    
Research here about modifying RSS feeds and try to improve the Question based on what you find. Helpful guide on How to Ask. –  brasofilo Apr 16 '13 at 23:16

1 Answer 1

I've never actually tried this, but I think the following should work:

function wpse_96096_append_author( $title, $post_id ) {
    if( is_feed() ) {
        $author = get_post_meta( $post_id, '{YOUR CUSTOM FIELD KEY}', true );
        $title = $title . ' by ' . $author;
    }
    return $title;
}
add_filter( 'the_title', 'wpse_96096_append_author', 10, 2 );

What this does is add a filter to the title field that is only applied when is_feed() returns true. When it does, it queries the custom field and tacks it on to the title.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.