admin管理员组文章数量:1315294
I can't seem to figure this out, I have tried and looked at multiple forums posts with example codes but nothing is working for me.
I have wordpress and a custom post type called videos-on-demand.
Video on demand post type has a few taxonomies like age, teachers, length of video, etc..
I created a test post and made a custom page that is working and I am able to customize it... however I can't get the taxonomies to show on the footer of the page similar to how you would see categories and tags on a standard blog post.
I want to be able to click on those terms/links to bring you to an archive of all those terms for searchability.
What am I missing here?
<?php
$terms = get_the_terms( $post->ID, 'video-on-demand' );
foreach($terms as $term) {
echo $term->name;
}
?>
I can't seem to figure this out, I have tried and looked at multiple forums posts with example codes but nothing is working for me.
I have wordpress and a custom post type called videos-on-demand.
Video on demand post type has a few taxonomies like age, teachers, length of video, etc..
I created a test post and made a custom page that is working and I am able to customize it... however I can't get the taxonomies to show on the footer of the page similar to how you would see categories and tags on a standard blog post.
I want to be able to click on those terms/links to bring you to an archive of all those terms for searchability.
What am I missing here?
<?php
$terms = get_the_terms( $post->ID, 'video-on-demand' );
foreach($terms as $term) {
echo $term->name;
}
?>
Share
Improve this question
asked Dec 14, 2020 at 20:59
MuhuPowerMuhuPower
1134 bronze badges
1 Answer
Reset to default 0The first line of code in your question appears to be the problem.
The get_the_terms()
function expects the post (object or ID) as the first parameter. The second parameter should be the taxonomy name, not your custom post type.
Something like this should work for you:
$age_terms = get_the_terms( $post->ID, 'age' );
$lang_terms = get_the_terms( $post->ID, 'language' );
get_the_terms( int|WP_Post $post, string $taxonomy )
https://developer.wordpress/reference/functions/get_the_terms/
本文标签: customizationDisplay multiple custom taxonomy values on single custom post types page
版权声明:本文标题:customization - Display multiple custom taxonomy values on single custom post types page? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741913555a2404587.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论