简体   繁体   English

WooCommerce-如何从网址中删除产品和产品类别?

[英]WooCommerce- How to remove product & product-category from urls?

I'm using WooCommerce on a WordPress and it adds product & product-category to the URLs. 我在WordPress上使用WooCommerce,它将产品和产品类别添加到URL。 http://dev.unwaveringmedia.com/8dim/product-category/all-party-supplies/ http://dev.unwaveringmedia.com/8dim/product/14-snowman-serving-tray/ 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? 有没有办法修改永久链接并删除它们?

Its good practice for SEO and UX to have a product category base. 它是SEO和UX的良好实践,拥有产品类别基础。 Product category bases help to distinguish products from posts. 产品类别基础有助于区分产品和帖子。 I usually change the product category base to "our-products" or "products". 我通常将产品类别基础更改为“我们的产品”或“产品”。

To do this go to settings->permalinks-> enter your desired product category base. 要执行此操作,请转到设置 - >永久链接 - >输入所需的产品类别库。

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. 不幸的是,由于WordPress解析其URL的方式,这是不可能的。 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. 它使用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? 您也可以“破解”核心代码,只需更改它们用于永久链接结构的字符串 - 或者这可能是其他地方提到的设置要做的事情?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM