Product Category Shortcodes

Use these two shortcodes to display product categories on any page of your WooCommerce store. The [product_category] shortcode displays products from a specific category, while [product_categories] displays a grid of your product categories.

  • [product_category] — Displays products belonging to a specified category. Requires the category attribute to identify which category to show.
  • [product_categories] — Displays a grid of product category tiles, each showing the category image, name, and product count. Supports filtering by ID, parent category, and sort order.

Insert a shortcode into a page

↑ Back to top

To add a product category shortcode to a page or post:

  1. Open the page or post in the WordPress block editor.
  2. Click the + inserter button and search for the Shortcode block.
  3. Add the block to your page and paste the desired shortcode into the text field.
  4. Click Publish or Update to save your changes.

If you use the Classic Editor, paste the shortcode directly into the page content area.

WooCommerce also provides product category blocks as a block-based alternative to shortcodes. For details, see the WooCommerce Blocks documentation.

product_categories shortcode attributes

↑ Back to top

The following attributes customize which categories the [product_categories] shortcode displays and how they appear:

  • ids — Specify category IDs to display. Only the listed categories appear.
  • limit — The number of categories to display. Enter 0 or leave undeclared to show all categories. Interchangeable with number.
  • columns — The number of columns to display. Defaults to 4.
  • hide_empty — Defaults to 1, which hides empty categories. Set to 0 to show empty categories.
  • parent — Set to a specific category ID to display all its child categories. Set to 0 to show only top-level categories.
  • orderby — Defaults to name. Other options include id, slug, and menu_order. To order by the IDs you specified, use orderby="include".
  • order — Sets whether the category ordering is ascending (ASC) or descending (DESC), using the method set in orderby. Defaults to ASC.

product_category shortcode attributes

↑ Back to top

The following attributes customize which products the [product_category] shortcode displays and how they appear:

  • category — The category ID, name, or slug. This attribute is required.
  • limit — The number of products to display. Defaults to showing all products in the category. Interchangeable with per_page.
  • columns — The number of columns to display. Defaults to 4.
  • orderby — Defaults to title. Other options include date, id, menu_order, popularity, rand, and rating.
  • order — Sets whether the product ordering is ascending (ASC) or descending (DESC). Defaults to ASC.

Shortcode examples

↑ Back to top

Display products from a specific category

↑ Back to top

To display products from a single category, use the [product_category] shortcode with the category attribute. You can use the category slug, name, or ID. The following example displays up to 8 products from the “clothing” category in 4 columns, ordered by popularity:

[product_category category="clothing" limit="8" columns="4" orderby="popularity"]

This shortcode produces a grid of product tiles from the specified category, each showing the product image, name, price, and an add-to-cart button.

Show top-level categories only

↑ Back to top

To display only top-level categories on a page and exclude subcategories, use the following shortcode. Setting parent to 0 limits the output to categories that have no parent, and setting number to 0 removes any limit on the number of categories shown.

[product_categories number="0" parent="0"]

The shortcode above produces a grid of top-level product category tiles, each showing the category image, name, and product count.

Grid of top-level product categories displayed on a storefront page using the product_categories shortcode

Questions and support

↑ Back to top

Do you still have questions and need assistance? 

This documentation is about the free, core WooCommerce plugin, for which support is provided in our community forums on WordPress.org. By searching this forum, you’ll often find that your question has been asked and answered before.

If you haven’t created a WordPress.org account to use the forums, here’s how.

  • If you’re looking to extend the core functionality shown here, we recommend reviewing available extensions in the WooCommerce Marketplace.
  • Need ongoing advanced support or a customization built for WooCommerce? Hire a Woo Agency Partner.
  • Are you a developer building your own WooCommerce integration or extension? Check our Developer Resources.

If you weren’t able to find the information you need, please use the feedback thumbs below to let us know.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.