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.
termcontext 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 quotesWe want to create a dedicated shop page that is limited to products from a Tops product category. It should allow visitors to search by keyword within the page and update the results dynamically. To achieve this, we place these shortcodes on a new page:
"to enclose the specified attributes.
[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.
taxonomy– One or more taxonomies separated by comma, used in combination with the term attribute. Any valid product taxonomy can be used, including
product_catfor product category,
product_tagfor product tags; for product attributes, use the
pa_prefix of the related taxonomy, e.g.
pa_sizefor a Size product attribute,
pa_colorfor 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"]