display only selected terms in custom node template How can I change the below code to display only the selected terms in the node. right now all terms which are defined in the vocabulary is displayed

&lt;?php 
$items = taxonomy_vocabulary_machine_name_load('test_categories');
$taxonomy = taxonomy_get_tree($items-&gt;vid);
foreach($taxonomy as $key =&gt; $items):
  print $items-&gt;name;
endforeach;
?&gt;
For specific node you need to use $info = node_load($nid) where you find your field value using $info->field_name. Using that field you can use foreach something like foreach($info->field_name as as $key => $items).