不存在类别URL与“商店基础”与类别合作。
我在永久链接设置中设置了“带有类别的商店基础”选项。
现在我的产品URL就是这样:
site.com/shop/category1/product1
但是,此URL也转到Product1:
site.com/shop/randomword/product1
没有类别这样的“随机字”,也没有site.com/shop/randomword/给出404个错误,但上述URL工作。它不会重定向到 /category1 /product1,而只是有效。
因此,remove_filter('template_redirect','redirect_caronical');
不起作用。它适用于其他帖子,但不适合产品。
有什么方法可以防止这种情况吗?
I set "Shop base with category" option in the Permalink Settings.
Now my product URLs are like that:
site.com/shop/category1/product1
However, this URL also goes to product1:
site.com/shop/randomword/product1
There is no category such "randomword" and also site.com/shop/randomword/ gives 404 error but the URL above works. It does not redirect to /category1/product1, it just works.
Therefore remove_filter( 'template_redirect', 'redirect_canonical' );
is not working. It works for other posts but not products.
Is there any way to prevent this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决方案。
该页面可与随机类别URL一起使用。因此,当URL不等于永久链接时,我决定将其重定向到永久链接。因此,当有一个随机URL时,它将重定向到实际URL。
您可以将此代码放在header.php中
输入时,
它重定向到
编辑:
代码打破了草案预览。需要指定它已发布。
I found a solution for this.
The page works with a random category URL. So when the URL is not equal to permalink I decide to redirect to permalink. So when there is a random URL, it redirects to actual URL.
You can put this code in the header.php
When you enter
it redirects to
Edit:
The code breaks the draft preview. Need to specify it is published.