How can I get the taxonomy "term" from the $taxonomy array. So far I have:

foreach ( $taxonomy as $key => $val )
{
print "$key
";
}

put this only prints strings like:
taxonomy_term_13, etc.

How can I get the actual word associated with this taxonomy?

I know I can use the $terms variable but that gaves me a HTML link, which I dont need, I just need a way to get the plain text word associated with this node.

Help please!!

Comments

nevets’s picture

You don't mention the context you are trying to do this in but if you have a node variable this should help

<?php
foreach ( (array)$node->taxonomy as $term ) {
// $term->name has the taxonomy term name
// $term->tid has the taxonomy term id
}
?>
r00tk1ll’s picture

Perfect that is exactly what I needed, your awesome. Here is what I ended up with:

foreach ( (array)$node->taxonomy as $term ) {
// $term->name has the taxonomy term name
// $term->tid has the taxonomy term id

$category = $term->name;
print $category;
}
Coupon Code Swap’s picture

Can this snippet be adjusted to only print a single term or a selection of terms?

tbeauchemin’s picture

I would also REALLY Like to be able to print only a specific vocabulary if that's possible

Izz ad-Din’s picture

if (term->vid == <yourvocabularyid>);

if i am not mistaken

UNarmed’s picture

Ah great i was looking for something similar =D