How to filter WooCommerce products by custom attribute

前端 未结 5 1351
-上瘾入骨i
-上瘾入骨i 2020-12-08 05:04

I\'m trying to filter WooCommerce product archive by custom attributes.

For example, there are 5 products with attribute \"color\" containing \"red\", and another 3

5条回答
  •  青春惊慌失措
    2020-12-08 05:48

    You can use the WooCommerce Layered Nav widget, which allows you to use different sets of attributes as filters for products. Here's the "official" description:

    Shows a custom attribute in a widget which lets you narrow down the list of products when viewing product categories.

    If you look into plugins/woocommerce/widgets/widget-layered_nav.php, you can see the way it operates with the attributes in order to set filters. The URL then looks like this:

    http://yoursite.com/shop/?filtering=1&filter_min-kvadratura=181&filter_max-kvadratura=108&filter_obem-ohlajdane=111

    ... and the digits are actually the id-s of the different attribute values, that you want to set.

提交回复
热议问题