1

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;
    }
?>
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.org/reference/functions/get_the_terms/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.