Jordan Carter
Jordan Carter

Reputation: 1336

WooCommerce URL to filter by attribute

I am trying to find out the URL I need to display products on my shop page based on an attribute. The attribute is called "Mantel Type" (slug mantel-type) and the term is "Mantel With Overmantel" (slug mantel-with-overmantel). The term has an ID of 106. I've tried the following URLs, but all products are displayed, rather than the expected 22, or I get a 404 error.

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 error)

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

I have made sure that the enable archives checkbox has been selected in the Mantel Type attribute editor.

I've had success with product categories, just not attributes. This product category link works, for example:

mysite.com/shop/?product_cat=french

How can I include attributes in the URL as well? Thank you for your time.

Upvotes: 3

Views: 14549

Answers (1)

blair dowis
blair dowis

Reputation: 21

Woocommerce attributes are just Wordpress taxonomies.

https://example.com/mantel-type/mantel-with-overmantel/ will get what you want. I imagine there is some way to get https://tart.dolcedev.com/shop/mantel-type/mantel-with-overmantel/ to go to what you want but I don't know enough about your wp setup to help with that.

You can also use get_term_link to generate these urls dynamically. https://developer.wordpress.org/reference/functions/get_term_link/

The urls with the "?" all go to the "shop" page. Anything in a url preceded by a ? is just a query string.

Upvotes: 2

Related Questions