This shortcode is provided with the WooCommerce Product Search extension.
This shortcode is used to establish a filter context as described below. It is not used to produce any particular output by itself.
- The shortcode determines the current filter context based on the attributes given.
- The shortcode must be placed within the page content. It will not work if it is placed in a widget or within a page builder’s block.
- The shortcode must only be used once per individual page.
- Combinations of taxonomies and terms can be used as detailed in the explanations provided for the attributes below.
taxonomy
and term
context parameters of the [woocommerce_product_filter_products]
shortcode. Using a separate shortcode instead can be clearer where the separation of context and rendering is more intuitive or simply more readable when you edit a page. It further allows to establish the context early within a page when needed, while the products and filter widgets can be placed independently.
Important: The shortcode must be placed within the page content. It will not work if it is placed in a widget or within a page builder’s block. Use the editor in plain Text mode to insert the shortcode and make sure that you use straight double quotes
"
to enclose the specified attributes.Example – Custom Shop Page based on a Category
↑ Back to top[woocommerce_product_filter_context taxonomy="product_cat" term="Tops"] [woocommerce_product_filter] [woocommerce_product_filter_products]
- The first shortcode is the one discussed here, it establishes the product category Tops as the current filter context.
- The shortcode on the second line simply adds a live search filter field on the page.
- And the one on the third line renders the matching products in the fashion of a usual shop page. The products that it will display will be limited to those of the Tops category.
Shortcode Attributes
↑ Back to toptaxonomy
– One or more taxonomies separated by comma, used in combination with the term attribute. Any valid product taxonomy can be used, includingproduct_cat
for product category,product_tag
for product tags; for product attributes, use thepa_
prefix of the related taxonomy, e.g.pa_size
for a Size product attribute,pa_color
for a Color product attribute, etc.term
– One or more terms can be given by name, slug or ID.
[woocommerce_product_filter_context taxonomy="product_cat" term="Cars"]– Include products from the Pants or from the Shorts product categories:
[woocommerce_product_filter_context taxonomy="product_cat" term="Pants,Shorts"]– Include products from the Dresses category that have colors red or orange related:
[woocommerce_product_filter_context taxonomy="product_cat,pa_color,pa_color" term="Dresses,red,orange"]Â