I’d like to add custom fields in my custom post type to the RSS feed for that post type located at http://example.com/feed/?post_type=my_custom_post_type
I’ve seen info on doing this for the regular feed but nothing for how to rewrite the custom post type feed.
I’ll need to add 10 – 15 items to the feed (1st act, 2nd act, 3rd act, price, purchase link…)
function add_custom_fields_to_rss() {
if(get_post_type() == 'my_custom_post_type' && $my_meta_value = get_post_meta(get_the_ID(), 'my_meta_key', true)) {
?>
<my_meta_value><?php echo $my_meta_value ?></my_meta_value>
<?php
}
}
add_action('rss2_item', 'add_custom_fields_to_rss');
You should be able to substitute and any other meta values you need to add to the feed.