I have a custom taxonomy called product_category
that holds products. How does one get the top-level parent term with a list of children terms?
I know how to get a global list of top-level terms using get_terms()
and passing in '0'
as the parent, but I only want the one that it related to the current archive page.
Example:
Magazines
–Glossy
—-Fashion
Books
–Hardcover
—-Adventure
If I happened to be on the Fashion archive, I only want to get Magazines with a list of child terms, not Books.
I think I figured it out. I ended up with the following:
Perhaps there is a better way to do this, but this seems to work fine.
I like that solution cbi. I can’t believe I’ve had such a difficulty getting this information when making a custom hierarchical taxonomy term archive.