How can I build an archive page for a custom post type and 2 taxonomies?


First I give you the elements that I have:

3 custom post types:

— community — artist — museum

4 custom taxonomies:

— countries, with the terms: denmark; sweden; finland etc.

— communities, with the terms: art festival; art fairs etc.

— artists, with the terms: painters, photographers, sculptors etc.

— museums, with the terms: museums, galleries, alternative spaces etc.

An example of what I would like to achieve with the archive is this:

having posts for the Community (custom post type) from the Countries (custom tax) for a specific term (Denmark).

Those posts should be listed by communities (custom tax) terms.

Then one should be able to switch to the Artist, or Museum (custom post type) for the same country and fetch the appropriate posts for each terms.

Of course I need to be able to do the same for each country.

I tried to create templates for each country like so:


and built a loop with the following code:

//start by fetching the terms for the communities taxonomy
$terms = get_terms( 'communities', array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0
) );
// run a query for each community
foreach( $terms as $term ) {

// Define the query
$args = array(
'post_type' => 'community',
'countries' => 'denmark',
'communities' => $term->slug
$query = new WP_Query( $args );

if ( $query->have_posts() ) {

echo'<h2>' . $term->name . '</h2>';

while ( $query->have_posts() ) : $query->the_post(); ?>

<article <?php post_class('col-sm-6 col-lg-4'); ?>>
<div class="article-container">
<h2 class="entry-title"><?php the_title(); ?></h2>
<div class="">
<?php the_content(); ?>

<?php endwhile;

// restore orginal query
} ?>

So far, this loop displays the list of posts for the communities terms

for the defined country just like I need, but the url for this page is:

How can I query another custom post type for the same country with such a url?

Is it possible to have the url write something like this:

Maybe with a mysterious plugin that I didn’t find yet?

If it’s possible, can you please explain how I could do that?

Then finally if it’s possible to have a url that have 2 different custom taxonomies,

I imagine I could create a loop with if — elseif statements to decide which taxonomies terms I want to have

and call the proper url to do it.

Unfortunately I can’t give you a link to this as I’m working on it locally,

but the live site has a version that shows what I’m trying to do:

In this version of the site, the all thing is built using pages.

The entire content has to be typed manually for each page.

This is why we are updating that part of the site, so it can be updated with posts.

I hope this was clear enough

Let me know if you need more information.