dongzhi5386 2014-10-14 22:07
浏览 21

类别基础不起作用(永久链接)

I set permalinks to Custom Structure with these settings: /postCategory/%category%/%postname%/. Also I set up Category Base to postCategory. And this will not work. When I visit post page I am getting page not found.

This produces:

for posts: example.org/postCategory/%category%/%postname% // this will output page not found
for categories: example.org/postCategory/%category% // this works

This doesn't work only when I use the same word for Category Base and for prefix in post URL (in this case postCategory).

So this doesnt work:

Custom Structure: /postCategory/%category%/%postname%/
Category Base:  postCategory

and this will work:

Custom Structure: /postCategory/%category%/%postname%/
Category Base:  postCategories

So my questions is how I can get this work. To have the same word for Category Base and in permalinks for post.

These are my permalinks settings:

http://pokit.org/get/img/8a33b710bf98f9e3658edaaf8343cc3b.jpg

EDIT:

I found something similiar here:

https://wordpress.stackexchange.com/questions/58471/including-category-base-in-a-post-permalink-results-in-404

But I don't really understand how to set this function "add_rewrite_rule" for my case:

I have this problem with my custom post type: "product" and custom taxonomy: "product_cat" and want to use "vaporizers" for category base and in permalinks for "product"

So this is my desired setting for permalinks:

http://pokit.org/get/img/bad3b8bea220768b60bb73d49657974a.jpg

And the result for category should be:

www.example.com/vaporizers/product_cat_name

For product:

www.example.com/vaporizers/product_cat_name/product_name

  • 写回答

1条回答 默认 最新

  • dongluan1901 2014-10-15 03:15
    关注

    The reason it's not working is because the category base internal rewrite rule takes precedence in the permalink structure rules (i.e. category rewrites come before post rewrites). So example.org/postCategory/%category% is interpreted as example.org/index.php?category_name=postCategory/%category% and, obviously, WordPress can't find such category, returning 404 page. It will never search for posts after it fails on the category.

    The only work around is to give one more base to a category or post... just like in you "and this will work" example. They have to be different, there's no other way.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度