admin管理员组文章数量:1193775
Here is what I am looking for:
Custom Post Type: partner
Archive: domain/partners/ (list all partners)
Custom Taxonomy: country
Archive: domain/partners/denmark/ (list all partners in a country)
Custom Taxonomy: city
Archive: domain/partners/denmark/copenhagen/ (list all partners in a country and in city)
Single: domain/partners/denmark/copenhagen/the-name-of-the-partner-post/
On the custom post type rewrite I have the following:
$rewrite = array(
'slug' => 'partners/%country%',
'with_front' => false,
)
It works fin with the following:
domain/partners/denmark/
domain/partners/denmark/copenhagen/
domain/partners/denmark/copenhagen/the-name-of-the-partner-post/
BUT I cannot find a rewrite solution that works with:
domain/partners/
Here is what I am looking for:
Custom Post Type: partner
Archive: domain.com/partners/ (list all partners)
Custom Taxonomy: country
Archive: domain.com/partners/denmark/ (list all partners in a country)
Custom Taxonomy: city
Archive: domain.com/partners/denmark/copenhagen/ (list all partners in a country and in city)
Single: domain.com/partners/denmark/copenhagen/the-name-of-the-partner-post/
On the custom post type rewrite I have the following:
$rewrite = array(
'slug' => 'partners/%country%',
'with_front' => false,
)
It works fin with the following:
domain.com/partners/denmark/
domain.com/partners/denmark/copenhagen/
domain.com/partners/denmark/copenhagen/the-name-of-the-partner-post/
BUT I cannot find a rewrite solution that works with:
domain.com/partners/
Share
Improve this question
asked Sep 6, 2022 at 10:19
Vayu RobinsVayu Robins
12 bronze badges
1 Answer
Reset to default 0There are probably a few ways to handle this, but I'm guessing the fact that you're using "/partners" in your taxonomy rewrites is messing things up for using "/partners" alone for the CPT.
I think I would probably use "/partners" for the CPT only, and then define a custom rewrite rule that determines what the parameters after the various slashes correspond to.
If you take a look at the examples on the reference page, you might get an idea of what I mean. Specifically, look at the one from Akira Tachibana on that page.
本文标签: Url rewrite with custom post type and taxonomy
版权声明:本文标题:Url rewrite with custom post type and taxonomy 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738433858a2086559.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论