I have a hierarchical custom taxonomy ("photos"), with 3 parent terms
- color
- location
- year
Each parent term has several children terms. I have associated the "photos" taxonomy with pages and have tagged a bunch of pages with the relevant terms for each page.
For example, one page has terms:
- red (child of "color")
- sf (child of "location")
- 2010 (child of "year")
What I would like to do is have some sort of conditional tag that displays the terms as such:
- Color: Red
- Location: SF
- Year: 2010
Where the terms are linked.
I have tried to set up a conditional has_term
but am blanking on how to echo the term from the array:
<strong>Color:</strong> <?php if( has_term( array( 'red', 'blue', 'green' ), 'photos' ) ) {
// do something here
}
?>
That code checks to see if any of the three terms ('red', 'blue', 'green') are associated with that page, and it works fine to test the term. I just do not know how to echo the active term.
I could always create taxonomies for each of what are now my parent level terms ("Color", "Location", and "Year"), but if there is another way to do it without separate taxonomies, that would be great.
Any suggestions would be very much appreciated.