根据属性过滤的WooCommerce URL

时间:2018-11-02 22:55:27

标签: wordpress woocommerce attributes

我正在尝试根据属性找出在商店页面上显示商品所需的URL。该属性称为“ 壁炉架类型”(子弹壁炉架类型),术语为“ 带有超壁炉架的壁炉架”(子弹壁炉架-with-overmantel )。该术语的ID为 106 。我尝试了以下URL,但是显示了所有产品,而不是预期的22,否则出现404错误。

mysite.com/shop/?attribute_mantel-type=Mantel+With+Overmantel

mysite.com/shop/?attribute_mantel-type=mantel-with-overmantel

mysite.com/shop/?taxonomy=pa_mantel-type?&tag_ID=106

mysite.com/shop/?filter_mantel-type=106

mysite.com/shop/?filter_mantel-type=Mantel+With+Overmantel

mysite.com/shop/?filter_mantel-type=mantel-with-overmantel

mysite.com/shop/?pa_mantel-type=Mantel+With+Overmantel(404错误)

mysite.com/shop/?pa_mantel-type=106(404错误)

我确保在“壁炉架类型”属性编辑器中选中了“启用档案”复选框。

我在产品类别方面取得了成功,只是没有属性。该产品类别链接有效,例如:

mysite.com/shop/?product_cat=french

如何在URL中也包含属性?谢谢您的宝贵时间。

1 个答案:

答案 0 :(得分:1)

Woocommerce属性只是Wordpress分类法。

https://example.com/mantel-type/mantel-with-overmantel/将得到您想要的。我想象有某种方法可以使https://tart.dolcedev.com/shop/mantel-type/mantel-with-overmantel/转到您想要的内容,但是我对您的wp设置了解得不够多,无法为此提供帮助。

您还可以使用get_term_link动态生成这些URL。 https://developer.wordpress.org/reference/functions/get_term_link/

带有“?”的网址全部转到“商店”页面。网址中是否有前缀?只是一个查询字符串。