So I have a custom taxonomy of continent which is linked to a custom post type of offices.

Under the continent category I have:

-- Germany
----- The Posts
-- United Kingdom
----- The Posts
-- Australia
----- The Posts
-- New Zealand
----- The Post

Ideally I'd like the HTML to look something like:

<li>The post</li>

What's the best way to go about this? I've been struggling to get the sub taxonomy and then get the posts.

Sorry if this question has already been posted, I couldn't find anything but I could be wrong.

Thanks in advance!

1 Answer 1


You can use tax_query for this purpose.

$the_query = new WP_Query( array(
'post_type' => 'offices',
'tax_query' => array(
    array (
        'taxonomy' => 'europe',
        'field' => 'slug',
        'terms' => 'germany',

) );

You can also use more then one term in this query.

  • Thanks, how could i get this into one big loop to loop through each taxonomy? Commented Nov 7, 2017 at 12:37
  • You can use get_taxonomies( ) function to get all taxonomies and loop through this array.
    – wpdd
    Commented Nov 7, 2017 at 12:54

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.