I have registered two custom taxonomies of 'location' and 'type' registered before my post type of 'chalet' and have the rewrite rules set to
'slug' => 'chalets/%location%'
'slug' => 'chalets/%type%'
'slug' => 'chalets'
respectively. The URL structure for archives that I need is:
.../chalets/
.../chalets/[location term] eg /chalets/val-thorens
.../chalets/[type term] eg /chalets/ski-chalet
This works to a point but the second rule (whichever taxonomy is registered second) overrides the first and so the first subsequently returns a 404. How can I have both rewrites work or am I asking for the moon on a stick?
I have registered two custom taxonomies of 'location' and 'type' registered before my post type of 'chalet' and have the rewrite rules set to
'slug' => 'chalets/%location%'
'slug' => 'chalets/%type%'
'slug' => 'chalets'
respectively. The URL structure for archives that I need is:
.../chalets/
.../chalets/[location term] eg /chalets/val-thorens
.../chalets/[type term] eg /chalets/ski-chalet
This works to a point but the second rule (whichever taxonomy is registered second) overrides the first and so the first subsequently returns a 404. How can I have both rewrites work or am I asking for the moon on a stick?
Share Improve this question edited Sep 27, 2019 at 12:00 Kevin Nugent asked Sep 27, 2019 at 11:54 Kevin NugentKevin Nugent 5631 gold badge8 silver badges20 bronze badges1 Answer
Reset to default 0You must use separate base for both custom taxonomies. For example:
default URL: /chalets/
location term URL: /chalets/location/%location%
type term URL: /chalets/type/%type%
Rewrite rules need to identify the requested custom taxonomy via URL. So, a base URL identifier is required in your case.