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
Add a comment  | 

1 Answer 1

Reset to default 0

The 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