Multiple Pretty Permalink Rewrites for Custom Taxonomies

I have a custom post type and two custom taxonomies. I’m already successfully rewriting the first taxonomy titled ‘type’ to website.com/post_type/tax_term. I am doing so by adding the following rewrite rules:

On the taxonomy:

$rewrite = array(
‘slug’ => ‘chalets,
‘with_front’ => false,
‘hierarchical’ => false,
);

and on the post type:

$rewrite = array(
‘slug’ => ‘chalets/%chalet_type%’,
‘with_front’ => false,
‘pages’ => true,
‘feeds’ => true,
);

Now with the addition of my new taxonomy titled ‘location’ I’ve switched to the following on the taxonomies:

$rewrite = array(
‘slug’ => ‘chalets/%chalet_type%’,
‘with_front’ => false,
‘hierarchical’ => false,
);

$rewrite = array(
‘slug’ => ‘chalets/%chalet_location%’,
‘with_front’ => false,
‘hierarchical’ => false,
);

and this on my post type:

$rewrite = array(
‘slug’ => ‘chalets’,
‘with_front’ => false,
‘hierarchical’ => false,
);

This almost works but it appears that whichever tax rewrite comes second in my code overwrites/overrides the first. My question therefore is how can I set my three rewrite rules for tax 1, tax 2 and post type so that both will rewrite thus:

website.com/post_type/type_tax_term

website.com/post_type/location_tax_term

Many thanks.

Read more here:: Multiple Pretty Permalink Rewrites for Custom Taxonomies

Leave a Reply

Your email address will not be published. Required fields are marked *