E-commerce

WooCommerce Shortcodes: Complete List, Attributes and Copy-Paste Examples

Every built-in WooCommerce shortcode in one table: [products] attributes, categories, add to cart, cart, checkout and account, with examples and fixes.

On this page
  1. All WooCommerce shortcodes
  2. [products] attributes explained
  3. Copy-paste examples
  4. Where to paste a shortcode
  5. Cart and Checkout blocks vs shortcodes
  6. Troubleshooting WooCommerce shortcodes
  7. FAQs
Key takeaways
  • WooCommerce shortcodes are bracket tags such as [products limit="4"] that show products, categories, add-to-cart buttons, cart, checkout and account pages anywhere.
  • They are built into WooCommerce, go in a Shortcode block, and attributes such as limit, columns, orderby, category and on_sale control what they show.
  • Category and tag attributes take slugs, not names, and only one of on_sale, best_selling or top_rated works per shortcode.

WooCommerce shortcodes are short tags in square brackets, such as [products limit="4"], that display products, categories, add-to-cart buttons, the cart, checkout and account pages anywhere on a WordPress page or post.

They are built into WooCommerce, so no extra plugin is needed. Paste them into a Shortcode block, and change what they show with attributes.

All WooCommerce shortcodes

ShortcodeWhat it showsMain attributes
[products]A grid of products, filtered and sortedlimit, columns, paginate, orderby, order, category, tag, attribute, terms, ids, skus, on_sale, best_selling, top_rated, visibility, class
[product_page]A full single product pageid or sku
[product_category]Products from one or more categoriescategory, limit, columns, orderby, order
[product_categories]A grid of product categories (not products)number, columns, orderby, order, hide_empty, parent, ids
[add_to_cart]Price and add-to-cart button for one productid or sku, show_price, style, class, quantity
[add_to_cart_url]The plain add-to-cart URL (text, not a button)id or sku
[shop_messages]WooCommerce notices (such as "added to cart") on non-Woo pagesNone
[woocommerce_cart]The cart pageNone
[woocommerce_checkout]The checkout pageNone
[woocommerce_my_account]The customer account and login pageNone
[woocommerce_order_tracking]An order tracking form (order ID and billing email)None

[products] attributes explained

  • limit: how many products to show. -1 shows all.
  • columns: products per row (default 4).
  • paginate: true adds page numbers; use it with limit.
  • orderby: title, date, id, menu_order, popularity, rand or rating.
  • order: ASC or DESC.
  • category and tag: comma-separated slugs (not names).
  • attribute and terms: filter by a product attribute, for example colour = blue.
  • ids and skus: show specific products.
  • on_sale, best_selling, top_rated: set to true. Use only one of these per shortcode.
  • visibility: visible, catalog, search, hidden or featured.

Copy-paste examples

Latest 8 products, 4 per row:

[products limit="8" columns="4" orderby="date" order="DESC"]

Products on sale:

[products limit="8" columns="4" on_sale="true"]

Best sellers:

[products limit="4" columns="4" best_selling="true"]

Featured products:

[products limit="4" columns="4" visibility="featured"]

One category, paginated, 12 per page:

[products category="t-shirts" limit="12" columns="3" paginate="true"]

Filter by attribute:

[products attribute="colour" terms="blue" limit="8"]

Specific products by ID:

[products ids="21, 35, 48" columns="3"]

Single product page and add-to-cart button:

[product_page id="99"]
[add_to_cart id="99" show_price="true"]

Top-level product categories, hiding empty ones:

[product_categories number="0" parent="0" hide_empty="1" columns="4"]

Find a product ID by hovering over the product in Products > All Products; the ID shows under the name. Find a category slug in Products > Categories.

Where to paste a shortcode

  1. Open the page in the block editor (Pages > All Pages > Edit).
  2. Click the + inserter and add a Shortcode block.
  3. Paste the shortcode, then click Update (or Save) and view the page. The editor shows the raw tag; the front end shows the output.

In Elementor, use the Shortcode widget. In classic widgets, a Text or Custom HTML widget works. In PHP templates, use echo do_shortcode('[products limit="4"]');.

Cart and Checkout blocks vs shortcodes

Stores set up on newer WooCommerce versions use the Cart block and Checkout block by default instead of [woocommerce_cart] and [woocommerce_checkout]. Some older payment, shipping or checkout field plugins only work with the shortcode version.

To switch back to the shortcode checkout:

  1. Go to Pages and edit the Checkout page.
  2. Select the Checkout block and delete it (or use the block's switch-to-classic option if your version shows one).
  3. Add a Shortcode block containing [woocommerce_checkout] and update the page.
  4. Repeat on the Cart page with [woocommerce_cart].
  5. Check WooCommerce > Settings > Advanced still points Cart and Checkout at these pages, then place a test order.

Keep the blocks if all your plugins support them; WooCommerce focuses new checkout features on the blocks.

Troubleshooting WooCommerce shortcodes

  1. The shortcode shows as plain text: it was pasted into a Paragraph or Code block. Move it to a Shortcode block, and replace curly quotes copied from a document with straight quotes.
  2. No products appear: the category uses a name instead of the slug, the products are drafts, out-of-stock items are hidden (WooCommerce > Settings > Products > Inventory), or the IDs are wrong.
  3. Layout looks broken or columns ignored: the theme overrides WooCommerce styles. Test with a default theme such as Storefront, or add custom CSS.
  4. Changes don't show: clear the page cache and any CDN cache. Shortcode output is cached like the rest of the page.
  5. Checkout shortcode shows a notice instead of the form: the cart is empty, or the page is not set as the Checkout page in WooCommerce > Settings > Advanced.

Edge case: best_selling and top_rated rely on sales and review data, so on a new store with no orders or reviews the order can look random.

Need custom product layouts or a checkout that works with your plugins? Our WooCommerce developer service can set it up. New to the platform? Start with what WooCommerce is and how it works.

FAQs

Do I need a plugin for WooCommerce shortcodes?

No. The shortcodes listed here are built into WooCommerce and work as soon as it is active.

How do I show products from one category with a shortcode?

Use [products category="your-category-slug" limit="8" columns="4"], using the category slug from Products > Categories.

What replaced the old [recent_products] and [sale_products] shortcodes?

The single [products] shortcode with attributes such as orderby="date" or on_sale="true". The older shortcodes still work for backward compatibility, but [products] is the recommended one.

Can I use WooCommerce shortcodes in Elementor?

Yes. Add the Shortcode widget and paste the shortcode into it.

Should I use the Checkout block or the checkout shortcode?

Use the block if your payment and checkout plugins support it. Switch to [woocommerce_checkout] if a plugin you rely on only works with the classic checkout.

Need help with your website?

I'm a freelance WordPress developer building fast, SEO-friendly websites since 2020. Tell me what you need and I'll reply with a plan and a fixed quote, usually within 24 hours.

Found this useful? Share it:
Contact

Let's build your next website

Available for freelance projects, agency white-label work and long-term maintenance. Feel free to pass this along to your team or company.

I reply within 24 hours, usually the same day. Your details are emailed to me, then WhatsApp opens so we can chat right away.

Chat now