I would like to display taxonomies within an RSS feed. I am able to display my custom fields as per Add Custom Fields to Custom Post Type RSS (Thank you to all the contributors of that post), but I am unable to display fields that contain taxonomy values. Here is the code I am using:
add_action('rss2_item', 'yoursite_rss2_item');
function yoursite_rss2_item() {
if (get_post_type()=='listings') {
$fields = array(
'listing_category',
'listing_type',
'listing_bedrooms',
'listing_city',
);
$post_id = get_the_ID();
foreach($fields as $field)
if ($value = get_post_meta($post_id,$field,true))
echo "<{$field}>{$value}</{$field}>\n";
}
}
Here are the 2 taxonomy fields that are not showing:
- "listing_category" - either "For Sale", "For Lease", or Both (multiple values).
- "listing_type" - 1 value containing "Condo", "House", "Land", or "Building".
Any help is greatly appreciated.