WP-URL重写-自定义帖子类型/父级冲突 [英] WP - URL rewrite - custom post type/parent conflict

查看:115
本文介绍了WP-URL重写-自定义帖子类型/父级冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为此困扰了一天,似乎无法找到解决方案(很明显,我只是找不到/看到它).

I've been having trouble with this for a day now and can't seem to find a solution (it's probably blatantly obvious I just can't find/see it).

我有一个自定义帖子类型,称为产品,其中:

I have a custom post type called product where:

'rewrite' => array( 'slug' => 'product' )

因此,我为该帖子类型创建的帖子具有以下网址:

So the posts that I create for that post type have the URLs:

  • example.com/product/first-product
  • example.com/product/second-product
  • example.com/product/third-product
  • example.com/product/first-product
  • example.com/product/second-product
  • example.com/product/third-product

等.

我还创建了一个名为产品信息页面,该页面的URL:

I've also got a page created called Product Info that has the URL:

  • example.com/product

我想创建一个页面,该页面具有产品信息作为其父级,因此具有URL example.com/product/newpage

I'd like to create a page that has Product Info as its parent and therefore has the URL example.com/product/newpage

对我来说,这会返回未找到的404页面,我猜这是因为WordPress重写了URL,并检查了 product 帖子类型的 newpage 而找不到它

For me this returns a 404 page not found, I'm guessing this is because WordPress rewrites the URL and checks the product post type for newpage and cannot find it.

在没有提供未找到404页面的WordPress的情况下,您该如何做?

How do you do this without WordPress giving a 404 Page Not Found?

推荐答案

这是of的冲突.

如果您对页面有相同的要求,而CPT也使用相同的信息,则会产生冲突.因此,对于您来说,您的CPT使用的是"product",您的页面也是如此.这是冲突的原因,并导致404.

You will get conflicts if you have the same slug for a page and a CPT that uses that too. So for you, your CPT is using 'product', and your page is too. That's conflicting and causing the 404.

将页面Product Info页面的子页重命名为product-info.

Rename your page Product Info page' slug to product-info.

出于安全目的,通过将永久链接缓存设置为默认值,保存然后将其保存为以前的内容来刷新它们.

For safety purposes flush your permalink cache by setting them to Default, saving, then saving them as what you had previously.

这篇关于WP-URL重写-自定义帖子类型/父级冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆