Use taxonomy_get_term_by_name when there are duplicate names across multiple taxonomy categories UPDATE: I see that most likely the best way to accomplish this is to grab the term id from $content['field_tags']. However I'm not sure how to do that.
Whenever I retrieve $content['field_tags'][value] all that gets returned is an array object. And when I attempt to render it all I get is the tag name.



I'm attempting to grab the taxonomy term id in the node template for a content type. I'm grabbing the taxonomy term by referencing the field that contains the taxonomy terms. Like so

$tag = render($content['field_tags'][$i]);


I then use taxonomy_get_term_by_name in order to grab the id for that term like so.

$term_array = taxonomy_get_term_by_name(render($content['field_tags'][$j]));
$term = reset($term_array);
$term_id = $term-&gt;tid;


It works like a charm except for one issue. I have a taxonomy category for tags as well as events, and when there is a term with the same name in both the 'event' and 'tags' category it grabs the event term id instead of from the 'tags' category, which I want.

Is there another way to grab the specific term id for the tag field? Would it be possible to grab the term id directly from this object?

$content['field_tags'][$j]
Yes, you should pull the term ID directly from the field value rather than first rendering it to a term name, then trying to look up the term based on the name.