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 badges1 Answer
Reset to default 1Inside 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
评论列表(0条)