0

I'm trying to print out the selected vocabulary from a content type on a page. As the previous user did not use views for this layout, I need to find a way to add it.

Here is my code so far.

foreach ( (array)$node->taxonomy as $term ) { echo $term->name; }?>

Right now, it shows all of the terms that are listed in my taxonomy. Is there a way to narrow this down? to only show selected vid?

Regards,

1 Answer 1

0

Answering my own question for future purposes:

<?php

$vocabularies = taxonomy_get_vocabularies(); if ($vocabularies) { foreach($vocabularies as $vocabulary) { if ($vocabulary->vid == 1) { $terms = taxonomy_node_get_terms_by_vocabulary($node, $vocabulary->vid); if ($terms) { foreach ($terms as $term) { print $term->name; } } } } } ?>

Did the trick.

Your Answer

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

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