0

I'd like to optionally replace some RSS item titles with a headline meta field I've added to certain post types.

I have the post types showing up in the feed using:

function myfeed_request($qv) {
  if (isset($qv['feed']) && !isset($qv['post_type']))
    $qv['post_type'] = array('post', 'interviews', 'reviews');
  return $qv;
}
add_filter('request', 'myfeed_request');

But I've searched around and can't figure out how to replace the title. Any ideas?

1 Answer 1

3

Something like this (not tested):

add_filter('the_title_rss', 'custom_feed_title');

function custom_feed_title($title) {

    $headline = get_post_meta(get_the_id(), 'headline', true);

    if (!empty($headline))
        return $headline;

    return $title;
}
0

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.