0

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?

1
  • Research here about modifying RSS feeds and try to improve the Question based on what you find. Helpful guide on How to Ask.
    – brasofilo
    Commented Apr 16, 2013 at 23:16

1 Answer 1

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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