Pull in taxonomy field of custom post type in new query

I have a Custom Post Type named companion. Via Companion I create articles which are then associated with my custom taxo

I have a Custom Post Type named companion. Via Companion I create articles which are then associated with my custom taxonomy issueCompanion. Imagine issueCompanion as a publication which is released periodically, like a magazine. I have another custom Taxonomy called 'topic' which acts like categories, and is associated with each article in companion.

I display this on the front-end via taxonomy-issueCompanion.php. On this page, I have to display the topic of each article, next to each article. The articles are easy to pull in because they come with the regular wordpress loop (if have_posts(), while have_posts()), but I can't seem to get to the topic taxonomy of each displayed article.

How do I display each article's corresponding issue? In other words, how do I display a custom taxonomy (topic) on a custom post type's post (companion)? I feel like I've done this 100 times but it doesn't seem to work for me this time.

Thank you for any input

I have a Custom Post Type named companion. Via Companion I create articles which are then associated with my custom taxonomy issueCompanion. Imagine issueCompanion as a publication which is released periodically, like a magazine. I have another custom Taxonomy called 'topic' which acts like categories, and is associated with each article in companion.

I display this on the front-end via taxonomy-issueCompanion.php. On this page, I have to display the topic of each article, next to each article. The articles are easy to pull in because they come with the regular wordpress loop (if have_posts(), while have_posts()), but I can't seem to get to the topic taxonomy of each displayed article.

How do I display each article's corresponding issue? In other words, how do I display a custom taxonomy (topic) on a custom post type's post (companion)? I feel like I've done this 100 times but it doesn't seem to work for me this time.

Thank you for any input

Share Improve this question asked Jun 24, 2019 at 18:36 HeweHewe 859 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Inside of your loop on the taxonomy-issueCompanion.php template file you can retrieve the terms of the taxonomy that are attached to the post.

// Inside of your while loop 
$post_topics = get_the_terms($post->ID, 'topic');

// And then you can do as you wish with your topics!

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745373917a4624916.html

相关推荐

  • Pull in taxonomy field of custom post type in new query

    I have a Custom Post Type named companion. Via Companion I create articles which are then associated with my custom taxo

    3小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信