Code snippet to print the terms associated to a node in Drupal 7
// we get the node ID if (arg(0) == 'node' && is_numeric(arg(1))) { $nid = arg(1); } $node = node_load($nid); // grab all terms without specifying field names and no db_query: function example_get_terms($node) { $terms = array(); foreach (field_info_instances('node', $node->type) as $fieldname => $info) { foreach (field_get_items('node', $node, $fieldname) as $item) { if (is_array($item) && !empty($item['tid']) && $term = taxonomy_term_load($item['tid'])) { $terms[] = $term->name; } } } return $terms; } $terms = example_get_terms($node);