How To Extract A Single Value from wp_get_post_terms
-
I want to display the term attached to a post in certain taxonomy.
I can get the taxonomy information for a post using
$sectiondata = wp_get_post_terms($post->ID, 'chapters', array("fields" => "all"));
Then using
print_r $sectiondata;
I can display the array of values returned.However, how do I echo the value for the ‘name’ of the term to the page?
I thought this should be something like:
echo $sectiondata->name;
But that returns nothing so I obviously don’t understand how to extract this value. I’ve searched around for examples and don’t see anything that explains how to display the value on the page, or perhaps better stated how to extract the value from the array. I’ve tried using the plain php approach of
print($sectiondata['name']);
But that doesn’t return anything either.Where can I find an explanation of how to extract the value from the array.
Thanks
- The topic ‘How To Extract A Single Value from wp_get_post_terms’ is closed to new replies.