• I have custom post type and associated taxonomies, i want to return a value of taxonomy within loop, what is the best way to do this?

    example. custom post type >> movies
    taxonomy is >>>>> actors

    now within loop i want to output the name of actor for a particular movie,,,

    i tried this

    <?php $terms = wp_get_post_terms($post->ID, 'actors',  array("fields" => "names"));
    						print_r($terms);?>

    this returns

    Array ( [0] => name of actor )

    can some one suggest a better query to get the single value from taxonomy or correct this one.
    Thanks

Viewing 1 replies (of 1 total)
  • I don’t think you need to correct this code, just use code like this to display the first result:

    <?php if ($terms) echo "Actor: {$terms[0]}"; ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Getting single value of taxonomy associated with post’ is closed to new replies.