How to preselect filters on-page?

Welcome to Product Filter for WooCommerce article guides.

Sometimes you will want to make a link to a certain page, but with the filters already selected in the Product Filter. This is easily achieved with the query parameters you can add to your page URL. Examples follow.

Product categories can be preselected with the product_cat parameter that goes into the URL. If you use , or + these will relate to OR and AND filtering.

https://my-url.com/my-page/?product_cat=my-slug
https://my-url.com/my-page/?product_cat=my-slug,my-slug-2
https://my-url.com/my-page/?product_cat=my-slug+my-slug-2

Product tags can be preselected with the product_tag parameter that goes into the URL. If you use , or + these will relate to OR and AND filtering.

https://my-url.com/my-page/?product_tag=my-slug
https://my-url.com/my-page/?product_tag=my-slug,my-slug-2
https://my-url.com/my-page/?product_tag=my-slug+my-slug-2

Product attributes can be preselected with the pa_{attribute-name} parameter that goes into the URL. Change the {attribute-name} to your attribute slug. If you use , or + these will relate to OR and AND filtering.

https://my-url.com/my-page/?pa_my-attribute-slug=my-slug
https://my-url.com/my-page/?pa_my-attribute-slug=my-slug,my-slug-2
https://my-url.com/my-page/?pa_my-attribute-slug=my-slug+my-slug-2

Min price and max price can be preselected using the min_price and max_price.

https://my-url.com/my-page/?min_price=100
https://my-url.com/my-page/?max_price=200
https://my-url.com/my-page/?min_price=100&max_price=200

On sale filter can be preselected using the sale_products.

https://my-url.com/my-page/?sale_products=on

In stock filter can be preselected using the instock_products.

https://my-url.com/my-page/?instock_products=in
https://my-url.com/my-page/?instock_products=out
https://my-url.com/my-page/?instock_products=both

Range filters can be preselected by adding these parameters.

Prices:
https://my-url.com/my-page/?rng_min_price=100
https://my-url.com/my-page/?rng_max_price=200
https://my-url.com/my-page/?rng_min_price=100&rng_max_price=200

Taxonomies:
https://my-url.com/my-page/?rng_min_product_cat=my-slug-1&rng_max_product_cat=my-slug-2
https://my-url.com/my-page/?rng_min_pa_my-attribute-slug=my-slug-1&rng_pa_my-attribute-slug=my-slug-2

And of course, you can combine all of these. So this will work too!

https://my-url.com/my-page/?product_cat=my-slug,my-slug-2&max_price=100&sale_products=on
https://my-url.com/my-page/?product_cat=my-slug,my-slug-2&product_tag=my-tag
https://my-url.com/my-page/?pa_my-attribute-slug=my-slug&instock_products=in&sale_products=on

Leave a Reply

Your email address will not be published. Required fields are marked *