The Ultimate Guide to WooCommerce Product Shortcodes

WooCommerce supports a long list of shortcodes that you can find here. This post covers only WooCommerce products shortcodes, which are the ones that display products only. Let’s go over them step by step.

Quick shortcodes to display your products

Display all products

If you want to display all products on your store, simply use this shortcode:

display all products shortcode

Display featured products

To display all WooCommerce featured products on your store, use this shortcode:

display all featured products shortcode

Display all on-sale products

To display all on-sale products, use this shortcode:

all sales products shortcode

Display all best selling products

To display best selling products, you can use this shortcode:

best-selling-products-shortcode

Customize the display of products with attributes

Now you know all the important shortcodes to display WooCommerce products. However, what if you want to specify how many products per line, per page…? This is where attributes come into play.

Specify how many products per row with columns

If I want to display three products per row, I’ll use this shortcode:

specify number of products per row

And sure enough, I have a page with all of my products, 3 items on every rows:

specify number of products per row

I only write the shortcode with products, however, the same logic can be applied to all the shortcodes above (featured_products, sale_products…)

Limit number of products to display with limit

If your store has many products, it’s wise to limit the number of products to display with the limit attribute.

For example, the following shortcode limit only 9 products to display:

Of course, you can combine multiple attributes together to achieve more complex display. The following shortcode display 10 products, 5 per line:

combine multiple shortcode attributes

Products pagination with paginate

In case you have multiple products and you want to display them in multiple pages, the paginate attribute is what you need. You also need to set how many products you want to display PER PAGE with the limit attribute.

For example, the following shortcode display all products in multiple pages, 4 products per row, 12 products per page:

Display products from specific categories

There are times you don’t want to display all products. Instead, you only need products from specific categories. In this case, you can specify the list of category slugs in your shortcode:

display-products-by-category

In this example, I want to list products from 3 categories which have their slug as hdd, ram, ssd accordingly.

How can you find product categories’ slugs? Simply go to Products->Category and look for the slug field of the categories you want:

how to find product category slugs

Set products’ order by order and orderby

By default, WooCommerce display products order by their title. However, you can change this behavior by using order, and orderby attributes.

The available value for orderby are:

date – The date the product was published.
id – The post ID of the product.
menu_order – The Menu Order, if set (lower numbers display first). This can be set for each product in product data tab
popularity – The number of purchases.
rand – Randomly order the products on page load (may not work with sites that use caching, as it could save a specific order).
rating – The average product rating.
title – The product title. This is the default orderby mode.

There are only two available value for order:

ASC: ascending, products that have lower value (as specified by orderby) come first

DESC: opposite of ASC

For example, I want to display all products, order by rating in descending order, I would use this:

Conclusion

As you can see, shortcodes can be very powerful if you them correctly. The list above is not exhaustive. If you have suggestion or request, please let me know.