Website Building » WooCommerce » How do I display a particular category product in WooCommerce shortcode?

How do I display a particular category product in WooCommerce shortcode?

Last updated on January 10, 2023 @ 2:56 pm

There are a few ways to display a category product in WooCommerce shortcode. One way is to use the category shortcode.

To use the category shortcode, you would add the following to your theme’s functions.php file:.

add_shortcode('product_categories', 'woo_product_categories');

Then, you would use the product_categories shortcode in your WooCommerce template to display the category products. For example, you could use the following code to display all the products in the ‘Footwear’ category:

[product_categories]= woo_product_categories();

Alternatively, you can use the WooCommerce category widget. To use the category widget, you would first add the WooCommerce category widget to your sidebar.

PRO TIP: If you are using a WooCommerce shortcode to display products from a particular category, be aware that the products will be displayed in alphabetical order by default.

Then, you would use the category_id custom field to identify the category product you want to display. For example, if you want to display the ‘Shoes’ category product, you would use the following code in your WooCommerce template:

<input id="category-product" name="category_id" type="text" />

Finally, you would use the widget in your shortcode to display the product. For example, you could use the following shortcode to display the ‘Shoes’ category product:

[product_categories category_id="shoes"]
Dale Leydon

Dale Leydon

Sysadmin turned Javascript developer. Owner of 20+ apps graveyard, and a couple of successful ones.