WooCommerce, Remote Work & Other Fancy Stuff

Just another WordPress site

WooCommerce Product Category Shortcode – Only Show Sale Items

May 15, 2015 by Will Leave a Comment

Perhaps you would like to showcase items on sale in a given product category – how can this be done? It’s quite trivial to use the WooCommerce provided Product category shortcode to display only products in that particular category. Likewise, it is just as easy to implement the WooCommerce provided Sale Products shortcode. But how is it possible to combine the two? It’s actually quite easy to do with a small code snippet. WooCommerce provides a filter called woocommerce_shortcode_products_query – which can be used to modify any of the shortcode product queries. Here is an example of how to use it when the product category shortcode is used, but you only want to output sale items:

Not sure what to do with code snippets? See What Do I Do With These Code Snippets?

Filed Under: WooCommerce Tagged With: shortcodes, snippet

Leave a Reply Cancel reply

You must be registered and logged in to post a comment.

© 2023 ยท WooCommerce, Remote Work & Other Fancy Stuff · Epstein didn't kill himself