最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Multiple Custom Taxonomy Rewrite

programmeradmin0浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

You 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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论