How to use categories in WooCommerce Protect Table
Our WooCommerce Product Table plugin fully supports product categories. You can add a ‘categories’ column to the product table, sort by category, filter by category, or even list products from specific categories or sub-categories. This article summarizes the different ways in which you can use categories with WooCommerce Product Table.
You can list each category as a separate column in the product table. Simply add
categories to your list of columns. The product categories will appear in a comma separated list.
You can rename the categories column to anything you like.
Parent and child categories/sub-categories are treated identically in the categories column. For example, in the following screenshot, ‘T-shirts’ is a child category of ‘Clothing’:
Displaying products with a specific category or sub-category
There are two ways to list products from a specific category only: by adding a shortcode to a page, or by automatically using the product table layout on all category archive pages.
Use a shortcode to list products by category
You can create a table listing products from one or more specific categories. For example, you can list products from the ‘women’ category only. This is a good way to pre-filter the table by category.
Add the product table layout directly to all category pages
You can enable the ‘Product category archives’ option on the plugin settings page to automatically use the product table layout on all your product category pages.
Filtering by category
There are two ways to let customers filter the table to refine the list of products based on their categories:
- Filter dropdown lists above the table.
- Use WooCommerce Product Table with a third party filter plugin to create category filter widgets
Sorting by category
You can sort the table by category – either when the table first loads, or by allowing customers to click on the header of the category column to sort by category.
If a product is in multiple categories then the first category will be used for sorting.
Can I list categories and sub-categories separately?
WooCommerce Product Table treats categories and sub-categories in exactly the same way, and doesn’t distinguish between the two.
The only ways to list categories and sub-categories separately are:
- Add a categories filter above the table, and the dropdown will list the categories in a hierarchical structure with the sub-categories nested/indented under the top level categories.
- Use the category shortcode option to list products from sub-categories separately on the page. For example, if your ‘clothing’ category has sub-categories for ‘t-shirts’ and ‘hoodies’ then you can create two products tables, one listing t-shirts and the other listing hoodies:
<h2>T-Shirts</h2> [product_table category="t-shirts"] <h2>Hoodies</h2> [product_table category="hoodies"]