This support ticket is created 5 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
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');