Skip Navigation

[Resolved] How to display posts custom taxonomy in an RSS feed

This thread is resolved. Here is a description of the problem and solution.

Problem:

The country that the person creating a post is from is stored in the custom taxonomy "Country". How can I display this in an RSS field?

Solution:

You can use wordpress function get_the_terms() to retrieve term's assigned to current post, for example:

https://toolset.com/forums/topic/how-to-display-posts-custom-taxonomy-in-an-rss-feed/#post-1192317

Relevant Documentation:

https://developer.wordpress.org/reference/functions/get_the_terms/

This support ticket is created 5 years, 2 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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 5 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#1192287

The country that the person creating a post is from is stored in the custom taxonomy "Country". How can I display this in an RSS field?

I can display a custom post type using something like this:
<dc:creator><![CDATA[<?php echo get_post_meta($post_id, "wpcf-posters-name", true); ?>]]></dc:creator>

Can I do something similar for the taxonomy without having to use a filter? I have a custom RSS feed which is why I'd rather not use a filter if possible.

#1192317

Hello,

You can use wordpress function get_the_terms() to retrieve term's assigned to current post, for example:

$terms = get_the_terms( get_the_ID(), 'country' );
foreach ( $terms as $term ) {
  echo $term->name;
}

More help:
https://developer.wordpress.org/reference/functions/get_the_terms/

#1193422

My issue is resolved now. Thank you!

#1193461

You are welcome

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.