Website Building » WooCommerce » How Do I Display WooCommerce Products by Subcategory?

How Do I Display WooCommerce Products by Subcategory?

Last updated on October 1, 2022 @ 4:20 pm

WooCommerce is a powerful eCommerce plugin for WordPress. It enables you to sell anything online, including products, subscriptions, and memberships. WooCommerce comes with a lot of features out of the box, including the ability to display products by subcategory.

In this article, we’ll show you how to display WooCommerce products by subcategory. First, we’ll create a subcategory.

Then, we’ll add some products to that subcategory. Finally, we’ll show you how to display the products on your website.

Creating a Subcategory

To create a subcategory in WooCommerce, go to Products > Categories. From there, you can add a new category or edit an existing one.

For our example, we’ll create a new category called “Shirts.” To do that, simply fill in the name field and click Add New Category.

Now that we have our category, we can add some products to it.

Adding Products to a Subcategory

To add a product to a subcategory in WooCommerce, go to Products > Add New product. From there, you can add all of the details about your product, including its name, price, description, and more.

Scroll down to the Product Data section and select the Categories tab. Here, you can choose which categories your product should be listed in. Simply check the box next to your desired category (in our case, “Shirts”) and click Publish.

Your product is now successfully added to your subcategory! You can repeat this process for as many products as you like.

Displaying Products by Subcategory on Your Website
Now that we have our products added to their respective subcategories, it’s time to display them on our website. There are two ways to do this: using the default WooCommerce layout or using a custom layout.

Let’s take a look at both methods.

1. Using the Default WooCommerce Layout:

If you want to use the default WooCommerce layout for displaying your products by subcategory, simply go to Appearance > Widgets. From there, drag and drop the “Product Categories” widget into your desired sidebar location.

2. Using a Custom Layout:

If you want more control over how your products are displayed by subcategory, you can use a custom layout. To do this, first create a new file called “archive-product_cat”. You can do this using a text editor like Notepad or TextEdit.

PRO TIP: If you are using a WooCommerce site, you may want to display products by subcategory. However, this may not be the best idea, as it can cause problems with your product pages. For example, if you have a product in multiple subcategories, it will be displayed multiple times on your site. This can make it difficult for customers to find the product they are looking for, and it can also create duplicate content issues for your site. If you do choose to display products by subcategory, be sure to use a plugin or extension that allows you to control how products are displayed, so that you can avoid these issues.

Next, paste the following code into your new file:

name; ?>

Once you’ve saved your file in the correct location (your themes folder > WooCommerce > archive-product_cat), you can preview it by going to Products > Categories and selecting your desired category from the list.

Your products should now be displayed by subcategory on your website!

Drew Clemente

Drew Clemente

Devops & Sysadmin engineer. I basically build infrastructure online.