I've been using WP for years, but this is my first time with taxonomies, so I need a little bit of help.

Like in the question How to show a hierarchical terms list? I have a taxonomy called places, which contains a hierarchical list of places (first level for countries, second level for cities, etc...).

A post can have an associated place: for example, we could take Berlin (child of Germany, child of Europe).

Now, the output I want is something like this:

Where: Berlin, Germany, Europe.

I've tried some solutions, but none works. I'm pretty sure that there must be a simple and clean solution...

1 Answer 1


wp_get_object_terms will give you the term assigned to the post, you could then use get_ancestors to get an array of the parent's IDs, then get_term_by ID to get the names and slugs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.