php WooCommerce-如何从网址中删除产品和产品类别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21130909/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WooCommerce- How to remove product & product-category from urls?
提问by Irfan
I'm using WooCommerce on a WordPress and it adds product & product-category to the URLs. http://dev.unwaveringmedia.com/8dim/product-category/all-party-supplies/http://dev.unwaveringmedia.com/8dim/product/14-snowman-serving-tray/
我在 WordPress 上使用 WooCommerce,它将产品和产品类别添加到 URL。 http://dev.unwaveringmedia.com/8dim/product-category/all-party-supplies/ http://dev.unwaveringmedia.com/8dim/product/14-snowman-serving-tray/
I need to remove 'product' & 'product-category' from the URLs. Is there any way to modify the permalinks and remove them?
我需要从 URL 中删除“产品”和“产品类别”。有没有办法修改永久链接并删除它们?
回答by rhysclay
Its good practice for SEO and UX to have a product category base. Product category bases help to distinguish products from posts. I usually change the product category base to "our-products" or "products".
SEO 和 UX 拥有产品类别库的良好做法。产品类别库有助于区分产品和帖子。我通常将产品类别基础更改为“我们的产品”或“产品”。
To do this go to settings->permalinks-> enter your desired product category base.
为此,请转到设置-> 永久链接-> 输入您想要的产品类别库。
回答by anonymous coward
There is an official answer to this in the WooCommerce documentation.
WooCommerce 文档中有对此的官方答案。
A snippet:
一个片段:
Unfortunately this is not possible due to the way WordPress resolves its URLs. It uses the ‘product-category' (or any other text for that matter) base of an URL to detect that it is an URL leading to a product category.
不幸的是,由于 WordPress 解析其 URL 的方式,这是不可能的。它使用 URL 的“产品类别”(或任何其他文本)基础来检测它是否是指向产品类别的 URL。
There is a bit of followup explanation, and allegedly there are some plugins that make it possible, though it's not recommended.
有一些后续解释,据称有一些插件可以实现,尽管不推荐。
You may also be able to 'hack' the core code and just change the strings they use for that permalink structure -- or maybe that's what the elsewhere-mentioned setting is intended to do?
您也可以“破解”核心代码,只需更改它们用于该永久链接结构的字符串——或者这可能是其他地方提到的设置的目的?

