WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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...

share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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