Archive page with multiple taxonomies rewrite

ok, so I thought I’d come back and answer my own question in case its useful to someone else.

To start, the CPT:

'query_var' => true,
    'has_archive' => false,
    'rewrite' => array(
        'slug' => 'resources',
        'with_front' => false
    ),

Tax1:

'query_vars' => true,
    'rewrite' => array( 
        'slug' => 'resources/type',
        'with_front' => false
    )

Tax2:

'query_vars' => true,
'rewrite' => array(
        'with_front' => false
    )

The rewrites:

add_rewrite_rule( '^resources/type/([^/]*)/industry/([^/]*)/?$', 'index.php?post_type=resources&resource_type=$matches[1]&industry=$matches[2]', 'top' );

This produces a slightly different URL structure than I originally intended, and while its a bit more verbose, I think it works just as well.

example.com/resources = page-resources.php

example.com/resources/type/white-papers = taxonomy-resource_type.php for Tax1 term white-papers.

example.com/resources/type/white-papers/industry/enterprise = the same taxonomy-resource_type.php archive template, but serves up only the CPT results of Tax1 AND Tax2.

This is exactly the functionality I was hoping to acheive.

Leave a Comment