I've got the following code in my functions.php which pulls some custom fields out of an Events post type and prepends them to the exerpt of the RSS feed.
Problem is that the functions works on ALL feeds whereas I really only want it to apply to the Archive feed for the Events post type.
How can I add a conditional to check for the post type?
// Additional RSS Content
$rss_more_content = '';
$rss_more_position = 'before'; // or "after"
// Function which adds content to RSS entries
function add_rss_content($content) {
global $rss_more_position, $rss_more_content, $post;
$metaValue1 = get_post_meta($post->ID, 'wpcf-start-date', true);
if(!empty($metaValue1)):
$metaDate1 = date("Y m d", $metaValue1);
endif;
$metaValue2 = get_post_meta($post->ID, 'wpcf-end-date', true);
if(!empty($metaValue2)):
$metaDate2 = date("Y m d", $metaValue2);
endif;
if(is_feed()) {
if ($rss_more_position == 'before') {
$content = "<p>$rss_more_content <b>$metaDate1</b> -> <b>$metaDate2</b></p>\n$content";
} else {
$content .= "<p>$rss_more_content <b>$metaDate1</b> -> <b>$metaDate2</b></p>\n";
}
}
return $content;
}
// Add hooks
add_filter('the_excerpt_rss', 'add_rss_content');