benhuson / wp-subtitle

Development of the WordPress WP Subtitle plugin. http://wordpress.org/plugins/wp-subtitle/
33 stars 16 forks source link

Include Subtitle in RSS Feed #6

Open lacymorrow opened 9 years ago

lacymorrow commented 9 years ago

Currently the subtitle does not get pulled into the RSS feed. I would like it to be displayed afterward. It looks like currently the only way to accomplish this is to override the feed generation functions but it would be great to see this feature included in future versions.

benhuson commented 9 years ago

Where a bouts would you want it included? As part of the RSS title? Or at the top of the content?

lacymorrow commented 9 years ago

That's a good question and my opinion shouldn't be seen as the answer. Subtitles may have different importance for different sites. In my case, they were direct afterthoughts to the real title. Ex... (not real titles) Title: New genetic breakthroughs Subtitle: Following a genetic counselor

In my case I appended to the title in the RSS feed, separated by a hyphen. E.g. New genetic breakthroughs - Following a genetic counselor

lacymorrow commented 9 years ago

Here is the code i used in functions.php:

/**
 * Custom RSS feed to attach subtitles to feed title
 */
// add custom feed content
function add_feed_subtitle($title) {
    if(is_feed()) {
        $subtitle = get_post_meta(get_the_ID(), 'wps_subtitle', true);
        if ($subtitle != ''){
            return $title . ' - ' . $subtitle;
        }
    }
    return $title;
}
add_filter('the_title', 'add_feed_subtitle');