WooCommerce · Guide
How to Use WooCommerce Shortcodes in WordPress: A Beginner's Guide

Short answer
To use WooCommerce shortcodes, edit a page or post, add a Shortcode block, paste a tag such as [products limit=“8” columns=“4”] and update the page. Change attributes like category, limit, columns and orderby to control which products appear and how they are arranged.
Key takeaways
- Shortcodes are bracketed tags that WooCommerce replaces with store content.
- Paste them into a Shortcode block, a builder shortcode widget or a widget area.
- The [products] shortcode covers most product grids through its attributes.
- Cart and checkout now default to blocks, but the classic shortcodes still work.
- Curly quotes and wrong slugs or IDs cause most shortcode problems.
What are WooCommerce shortcodes?
WooCommerce shortcodes are small bracketed tags, such as [products] or [woocommerce_cart], that tell WooCommerce to print store content wherever you place them.
A shortcode is a WordPress feature, not something unique to WooCommerce. WordPress scans post content for registered tags and swaps each one for the output of a PHP function, as explained in the Shortcode API handbook.
WooCommerce registers its own set of tags. Some build whole store pages, like the cart and checkout. Others show product grids, single products, categories or add to cart buttons inside any page or post.
They are useful when your theme or page builder does not offer a WooCommerce block for the layout you want. They also work in widget areas, classic editor content and many page builders.
Which WooCommerce shortcodes are available?
WooCommerce offers page shortcodes for the cart, checkout, account and order tracking, plus display shortcodes for products, categories and add to cart buttons.
The full list with every attribute lives in the official WooCommerce shortcodes documentation. These are the ones most stores use:
| Shortcode | What it shows | Typical use |
|---|---|---|
| [woocommerce_cart] | The cart page contents | Cart page |
| [woocommerce_checkout] | The checkout form | Checkout page |
| [woocommerce_my_account] | Login form or customer dashboard | My Account page |
| [woocommerce_order_tracking] | Order tracking form | Custom tracking page |
| [products] | A grid of products with filters | Landing pages, home page |
| [product_page id=“99”] | A full single product page | Sales or campaign pages |
| [product_category category=“hoodies”] | Products from one category | Category landing pages |
| [product_categories] | A grid of category thumbnails | Shop overview pages |
| [add_to_cart id=“99”] | A price and add to cart button | Blog posts, comparison pages |
| [add_to_cart_url id=“99”] | The bare add to cart URL | Custom buttons and links |
| [shop_messages] | Store notices, such as added to cart | Custom page layouts |
Older shortcodes such as [recent_products], [featured_products] and [sale_products] were folded into the [products] shortcode years ago. Use attributes on [products] instead, which gives you one tag to learn.
How do you add a WooCommerce shortcode to a page?
Edit the page, add a Shortcode block, paste the shortcode into it, then update the page and view it on the front end.
Step by step in the block editor:
- Go to Pages and open the page you want to edit
- Click the plus icon and search for Shortcode
- Insert the Shortcode block where you want the content
- Paste your shortcode, for example [products limit=“8” columns=“4”]
- Click Update, then view the page
The Shortcode block documentation covers the block itself. You can also paste a shortcode into a Paragraph block and it usually works, but the dedicated block is cleaner and avoids smart quote problems.
If you build pages with Elementor or another builder, use its shortcode widget instead. Our guide on editing shortcodes in Elementor shows where that widget sits.
In the classic editor, paste the shortcode straight into the content area on its own line. Use the Text tab if the Visual tab keeps changing your quote marks.
How do you use the [products] shortcode?
The [products] shortcode shows a grid of products, and its attributes decide which products appear, how many, in what order and in how many columns.
It is the most flexible WooCommerce shortcode. A plain [products] tag shows a default grid, but you will nearly always add attributes.
Common attributes include:
- limit sets how many products show, for example limit=“12”
- columns sets how many products sit in each row
- orderby sorts by date, price, popularity, rating, title, menu_order or rand
- order chooses ASC or DESC
- category filters by product category slug, with commas for several
- tag filters by product tag slug
- ids or skus pick exact products
- on_sale, best_selling and top_rated switch to special lists
- visibility can show only featured products with visibility=“featured”
- paginate adds page numbers when set to true
A few working examples:
[products limit="8" columns="4" orderby="date" order="DESC"]
[products category="hoodies,t-shirts" columns="3"]
[products on_sale="true" limit="6"]
[products best_selling="true" limit="4"]
[products ids="12,45,78" orderby="post__in"]
[products limit="12" columns="4" paginate="true"]
Use the category slug, not the category name. You can find slugs under Products > Categories in your dashboard.
Our guide on showing product categories in WooCommerce covers other ways to display category content.
How do you show a single product or add to cart button?
Use [product_page id=“99”] to show a full product page inside any page, or [add_to_cart id=“99”] to show just the price and add to cart button.
To find a product ID, go to Products > All Products and hover over the product name. The ID appears in the row actions under the title.
The [product_page] shortcode outputs the full product layout, including images, description, variations and the add to cart form. It is handy for campaign pages that focus on one item.
The [add_to_cart] shortcode is lighter. It suits blog posts and reviews where you only want a buy button next to your text. You can pass show_price=“false” to hide the price, or use sku instead of id.
For a fully custom button, [add_to_cart_url id=“99”] returns only the URL. Put it in a Button block link field and the button adds that product to the cart.
Should you use shortcodes or blocks for the cart and checkout?
New WooCommerce stores use the Cart and Checkout blocks by default, but the classic [woocommerce_cart] and [woocommerce_checkout] shortcodes still work and some extensions still need them.
Since WooCommerce 8.3, fresh installs create cart and checkout pages with blocks. Older stores often still use the shortcodes. Both are supported, as the WooCommerce cart and checkout blocks documentation explains.
Switch back to shortcodes if a payment gateway, delivery date plugin or checkout field add-on you rely on does not support the blocks. Otherwise the blocks give you a more modern layout and easier visual editing.
We compare both approaches in detail in WooCommerce cart and checkout blocks vs shortcode.
To switch a page back to the shortcode, edit the Checkout page, remove the Checkout block, add a Shortcode block with [woocommerce_checkout], and update. Then check that WooCommerce > Settings > Advanced still points to that page.
How do you use shortcodes outside the page content?
You can place WooCommerce shortcodes in widget areas with a Shortcode block, and in theme files with the do_shortcode() function.
In a block based widget area, go to Appearance > Widgets, add a Shortcode block and paste the tag. In a block theme, open Appearance > Editor and add a Shortcode block to the template part you want, such as the sidebar or footer.
Developers can print a shortcode from a template file:
<?php echo do_shortcode( '[products limit="4" columns="4" best_selling="true"]' ); ?>
The do_shortcode() reference explains how the function works. Put template changes in a child theme so updates do not wipe them.
Some page builders and theme fields do not run shortcodes automatically. If a field prints the raw tag, check whether the builder offers a shortcode widget for that area.
Why is a WooCommerce shortcode not working?
A shortcode usually fails because of curly quotes, a wrong slug or ID, a disabled WooCommerce plugin, or a theme or builder field that does not process shortcodes.
Work through these checks:
- Raw text on the page. WooCommerce may be deactivated, or the field does not run shortcodes. Confirm the plugin is active and use a Shortcode block.
- Curly quotes. Copying from documents can turn straight quotes into curly ones, which breaks attributes. Retype the quote marks.
- No products shown. The category slug, tag or ID is wrong, or the products are drafts, hidden or out of stock with hiding turned on.
- Wrong layout. Your theme controls product grid styling. The columns attribute sets the grid, but the theme decides spacing and card design.
- Cached output. A caching plugin may serve an old version. Clear the cache after editing.
If cart or checkout pages break after changes, see our guide on fixing the WooCommerce checkout.
For cart-only problems, our guide to a broken cart page walks through the usual causes.
Never cache the cart, checkout or My Account pages. Most caching plugins exclude them automatically, but check if you use custom page URLs.
What are some practical ways to use WooCommerce shortcodes?
Shortcodes work well for curated product sections on the home page, product picks inside blog posts, category landing pages and quick sales pages.
Some ideas you can copy:
- A new arrivals row on the home page with [products limit=“4” columns=“4” orderby=“date” order=“DESC”]
- A sale section with [products on_sale=“true” limit=“8”]
- A gift guide post with [products ids=“12,45,78” orderby=“post__in”] so items appear in your chosen order
- A category landing page with [product_category category=“hoodies” limit=“12” columns=“3”]
- A review article that ends with [add_to_cart id=“99”]
Keep each grid small on pages that also carry text. Large grids slow the page and push your content down.
For deeper layout control of store pages, read our guide on customizing WooCommerce pages.
Are WooCommerce shortcodes still worth learning?
Yes, shortcodes remain a reliable, portable way to show store content, even as WooCommerce moves toward blocks for most new layouts.
WooCommerce now ships blocks such as Product Collection, All Products and Single Product. These blocks give a visual preview while you edit, which shortcodes do not.
Shortcodes still win when you work in widget areas, page builders, classic themes or custom templates. They are also easy to copy between sites.
A sensible approach is to use blocks in the block editor where they cover your needs, and keep shortcodes for everything else. The source code for both lives in the WooCommerce GitHub repository if you want to see how they work.
Frequently asked questions
Where do I find WooCommerce shortcodes?
The official WooCommerce documentation lists every core shortcode with its attributes. Extensions such as subscriptions or bookings add their own, listed in each extension's documentation.
How do I find a WooCommerce product ID for a shortcode?
Go to Products > All Products and hover over the product name. The ID appears in the small row of links under the title. You can also see it in the post= value of the edit screen address.
Can I use WooCommerce shortcodes in Elementor?
Yes. Drag the Shortcode widget onto the page and paste your tag. Elementor Pro also has its own WooCommerce widgets, which give more visual styling options than shortcodes.
Do WooCommerce shortcodes slow down my site?
A small grid has little effect. Large grids with many products, random ordering or pagination add database queries, so keep grids modest and use page caching on pages that are not the cart, checkout or account pages.
What replaced [recent_products] and [featured_products]?
The [products] shortcode replaced them. Use orderby=“date” for recent products and visibility=“featured” for featured products, along with limit and columns.
Sources
- WooCommerce Shortcodes WooCommerce Documentation
- Shortcodes WordPress Plugin Handbook
- Shortcode Block WordPress.org Documentation
- do_shortcode() WordPress Code Reference
- Cart and Checkout Blocks WooCommerce Documentation
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
Related guides
About the editors
Researched from the primary sources listed above and checked against our editorial rules before publishing.


