Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon Woocommerce shortcode for product category


Woocommerce shortcode for product category


To display products from a specific category in WooCommerce, you can use the following shortcodes:

Shortcodes for Product Categories

1. Display Products in a Specific Category - Use the shortcode `[product_category category="your-category-slug"]` to show products from a specific category. Replace `your-category-slug` with the actual slug of the category you want to display.
- You can also add attributes to customize the display:
- `limit`: Number of products to display.
- `columns`: Number of columns for the layout (default is 4).
- `hide_empty`: Set to "1" to hide empty categories or "0" to show them.
- `orderby`: Options include "name", "id", "slug", etc.
- `order`: Set to "ASC" or "DESC" to control the order of displayed products[1][2][5].

Example:

plaintext
   [product_category category="clothing" limit="12" columns="4" orderby="name" order="asc"]
   

2. Display All Product Categories - To display all product categories, use the shortcode `[product_categories]`. This will list all categories available on your site.
- You can customize it with attributes like:
- `number`: Limit the number of categories displayed.
- `orderby`: Control the ordering of categories.
- `hide_empty`: To show or hide categories without products.
- `parent`: To display only top-level categories[2][3].

Example:

plaintext
   [product_categories number="0" parent="0" orderby="name" order="asc"]
   

These shortcodes can be added to any page or post in your WordPress site, either in a shortcode block (if using the block editor) or directly in the content (if using the classic editor) to dynamically display your products and categories.

Citations:
[1] https://woocommerce.com/document/woocommerce-shortcodes/
[2] https://woocommerce.com/document/woocommerce-shortcodes/product-category/
[3] https://www.storeapps.org/woocommerce-categories-shortcodes/
[4] https://woocommerce.com/document/woocommerce-product-search/shortcodes/woocommerce_product_filter_category/
[5] https://barn2.com/blog/woocommerce-shortcodes/