How to Display Products by Category Shortcode WooCommerce

WooCommerce Display Products by Category Shortcode

Are you looking for a way to display products by category shortcode in your WooCommerce store? WooCommerce provides you with different shortcodes.

They allow you to add various types of functionality anywhere on your site. This can be on your post, pages, widget, sidebar, header, etc.

It is important to learn more about WooCommerce shortcodes because they allow you to implement functionality without touching a single line of code.

If you are an advanced developer, you can register your own shortcode in the WordPress core, and use it anywhere on your site.

 WooCommerce Display Products by Category Shortcode

In this brief tutorial, we are going to use WooCommerce shortcodes that allow you to display products from a specific category.

Before you proceed, we recommend checking the list of all the WooCommerce shortcodes available. You can use them for your Cart, Checkout and My Account pages, etc. to display the content.

Let us see how you can display products by category using a shortcode.

Display Products by Category Shortcode

Product Categories allow you to add product categories loop and output with this shortcode:

[product_category category=“category name”]. You can paste it anywhere on your site but remember to use an existing category name.

For illustration purposes, we will display the ‘springs’ category on a page called ‘Springs Page’:

springs page

This is the outcome:frontend

For the categories section, here are seven more attributes you can apply to this shortcode:

  • ‘number’ => ‘null’, – This shortcode represents the number of categories.
  • ‘orderby’ => ‘name’, – This shortcode represents the order, “name” and “date” are valid options.
  • ‘order’ => ‘ASC’, – This shortcode represents how product categories are ordered, “ASC” or “DESC“.
  • ‘columns’ => ‘4’, – This shortcode defines the number of columns categories are organized into.
  • ‘hide_empty’ => ‘1’, – This shortcode represents Set to 1 to hide categories with no products or 0 to show them.
  • ‘parent’ => ”, – This shortcode represents Set to 0 to only display top-level categories.
  • ‘ids’ => ” – This shortcode represents that IDs can be set to only output specified results.

Displaying Products Category by Slug

This is similar to product categories but this allows you to add all your products within the defined category and can be adjusted with the per_page=“” and columns=“” parameters.

Here is the shortcode: [product_category category=“” per_page=“16″ columns=“3″ orderby= “date” order=“desc”].use slugs

This is the outcome:Display by slug

Conclusion

That’s all you need to do when you want to display products by category using a shortcode.

You can modify the shortcode using attributes and paste them anywhere on your site.

We hope our tutorial helped to solve your problem.

Similar Articles

  1. 100+ Tips, Tricks & Snippets Ultimate WooCommerce Hide Guide
  2. How to Display Stock Availability Text in WooCommerce » In Stock & Out
  3. How to Display Category Names in WordPress Using a Practical Example