How To Display Particular Category Product In Woocommerce Shortcode

WooCommerce stands out as a widely used e-commerce plugin for WordPress, enabling users to seamlessly set up and operate an online storefront. Among its numerous functionalities is the capability to showcase products from designated categories by utilizing shortcodes. In this piece, we’ll guide you through the process of accomplishing exactly this.

Step 1: Create a Shortcode

To display products from a particular category in WooCommerce, you need to create a shortcode. A shortcode is a small piece of code that can be used to insert content into your website. To create a shortcode for displaying products from a specific category, follow these steps:

  1. Log in to your WordPress dashboard and go to “Plugins” > “Editor”.
  2. Find the file “woocommerce/includes/wc-shortcodes.php” and click on it.
  3. Add the following code at the bottom of the file:
  4. [products category="YOUR_CATEGORY_SLUG"]
  5. Replace “YOUR_CATEGORY_SLUG” with the slug of the category you want to display products from.
  6. Save your changes and exit the editor.

Step 2: Use the Shortcode in Your Content

Now that you have created a shortcode for displaying products from a specific category, you can use it in your content. To do this, simply add the following code to your page or post where you want to display the products:

[products category="YOUR_CATEGORY_SLUG"]

Step 3: Customize Your Shortcode

If you want to customize your shortcode and display products from multiple categories, you can do so by adding additional parameters. For example, if you want to display products from two categories, you can use the following code:

[products category="YOUR_CATEGORY_SLUG1,YOUR_CATEGORY_SLUG2"]

Conclusion

Displaying products from a particular category in WooCommerce is easy with the help of shortcodes. By following these simple steps, you can create and customize your own shortcode to display products from any category you choose.