【发布时间】:2014-10-14 22:07:16
【问题描述】:
我使用以下设置将永久链接设置为Custom Structure:/postCategory/%category%/%postname%/。
我还将Category Base 设置为postCategory。
这是行不通的。当我访问帖子页面时,我找不到页面。
这会产生:
for posts: example.org/postCategory/%category%/%postname% // this will output page not found
for categories: example.org/postCategory/%category% // this works
只有当我对 Category Base 和帖子 URL 中的前缀(在本例中为 postCategory)使用相同的词时,这才起作用。
所以这不起作用:
Custom Structure: /postCategory/%category%/%postname%/
Category Base: postCategory
这将起作用:
Custom Structure: /postCategory/%category%/%postname%/
Category Base: postCategories
所以我的问题是如何才能完成这项工作。在Category Base 和帖子的永久链接中使用相同的词。
这些是我的永久链接设置:
http://pokit.org/get/img/8a33b710bf98f9e3658edaaf8343cc3b.jpg
编辑:
我在这里找到了类似的东西:
但我真的不明白如何为我的情况设置这个函数“add_rewrite_rule”:
我的自定义帖子类型存在这个问题:“产品”和自定义分类:“product_cat”,并且想将“vaporizers”用于类别库并在“产品”的永久链接中使用
所以这是我想要的永久链接设置:
http://pokit.org/get/img/bad3b8bea220768b60bb73d49657974a.jpg
类别的结果应该是:
www.example.com/vaporizers/product_cat_name
对于产品:
www.example.com/vaporizers/product_cat_name/product_name
【问题讨论】:
-
这很有趣。我在 WP 中发现了类似的奇怪之处,它拒绝允许我在 url 结构中使用某些单词,例如“搜索”——唯一的解决方法是不使用该单词。也许 postCategory 以某种方式被保留,他们的错误系统并没有考虑到这一点来告诉你为什么你不能使用它......只是一个理论。
-
我不认为 postCategory 以某种方式被保留,它现在只是 postCategory 如果您在 Category Base 和 post 永久链接中使用相同的词,则会出现问题。所以它也可能是 Custom Structure: /somethingElse/%category%/%postname%/ 和 Category Base: somethingElse 它仍然不起作用。所以我认为它会混淆,因为两个不同的东西会有相似的 URL