I have a custom post type named movies and taxonomy is genres.
Now there's a movie "random" with genres "horror" "drama" "adventure"

What I want to do is: list all of the associated genres on that movie page and when you click on a genre it links to that genre page. How can I do that.

1 Answer 1


You might have already figured this out, but here's an example how to get custom taxonomy terms for a post and create a list of links for the found terms.

// used in your custom post type template, e.g. single-movies.php
$genres = get_the_terms( get_the_ID(), 'genres' );
// current post has genre terms attached to it
if ( $genres && ! is_wp_error( $genres ) ) {
  $term_links = array();
  // build list item links
  foreach ($genres as $genre) {
    $genre_links[] = sprintf(
      '<li><a href="%s">%s</a></li>',
      esc_url(get_term_link($genre->term_id, $genre->taxonomy)),
  // display genres link list
    implode('', $genre_links)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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