I have a post type called venues, and each post type has a list of values to choose from in my custom taxonomy 'location'.


  • London (top level)
    • West London (2nd level)
    • North London (2nd level)
    • East London (2nd level)
      • Hackney etc.. (3rd level)

I would like to find results that match the lowest tier of taxonomy first, if there aren't any posts, then it will get results from the next taxonomy up, and so on. Each time the venue only has 1 value on each tier of the location taxonomy.

Any help much appreciated.

One thing that may help me write the code is if I knew how to load a taxonomy value by its term_id. Or if I could somehow determine the of the current taxonomy in relation to its parents.


1 Answer 1


I was able to solve this by ordering my taxonomy values based on this post:

Custom taxonomy, get_the_terms, listing in order of parent > child

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.