Rewriting Woocommerce Product Filters To URL Segments

Question

I’m working with a site where product category pages are filtered using query parameters:

?color=red&brand=nike&size=10

I’d like to use URL segments instead and rewrite the request to the above, for example:

/color/red/brand/bike/size/10

The thing is, there are 10 or so of these filters and they’re only applied when they’re used. So the URL could be:

/brand/nike

So a simple regex solution wouldn’t work, to my knowledge as the indexes aren’t always the same. The order of the keys and values will be the same, but some could be missing.

Are WordPress rewrites the right way to go about this, or do I need to look at hooking into Woocommerce’s queries?

Thanks

0
, , Daniel Dewhurst 4 years 2019-11-04T09:43:56-05:00 0 Answers 93 views 0

Leave an answer

Browse
Browse