Creating tables with specific products based on category, taxonomy, custom field, date & more
WooCommerce Product Table comes with lots of options for choosing which products are included or excluded in the table. You can display products with a specific category, tag, custom taxonomy term, custom field, date (year, month or day) or status. You can also show or hide specific products from the table based on their ID, and exclude certain categories.
category option lets you display products from a specific category (or subcategory). You can use the category slug or ID. This can be found in the Products > Categories section in WordPress.
You can specify multiple categories to display in the table – either separated by commas or by a plus sign (+). Using commas means “products in this category OR that category”. Using a plus means “products in this category AND that category”. You can’t mix and match commas and pluses – you have to use one or the other.
For example, to display products which are in the “courses” category or in the “books” category, use:
To display posts which are in the “courses” category and in the “featured” category, use:
Can I list categories and sub-categories separately?
All products are displayed in a single list, regardless of whether they are in a parent category or child category.
If you want to list products separately based on their category, then we recommend adding multiple tables to the page. Each table should list products from a different category or subcategory. You can divide up the page by adding the category name as a subheading above each table.
tags option lets you display products based on their tags. Use the tag slug or the ID – you can find this in WordPress within the Products > Tags section.
As with categories, you can use one tag or several tags, and you can use commas or a plus sign to control the logic. Using commas means “products with this tag OR that tag”, whereas using the plus sign (+) means “products with this tag AND that tag”. You can’t mix and match commas and pluses – you have to use one or the other.
Example 1: Display products with the tag “awesome”:
Example 2: Display products with any of the tags “cool”, “awesome” or “good”:
Example 3: Display products with all of the following tags: “cool”, “awesome” and “good”:
Custom taxonomy term
term option lets you display only products which have the specified term or terms. The taxonomy that you are selecting from doesn’t have to be a column in your table.
Enter in this format:
term="<taxonomy slug>:<term slug or ID>". You can enter one term or multiple terms, and as with categories and tags, you can separate terms using a comma (,) or a plus sign (+) to denote whether products have any of the terms specified or all of them.
You need to prefix this option with the slug of the taxonomy followed by a colon. For example, to display products that have the term
example in custom taxonomy
product_type, we would use:
[product_table columns="name,description,price" term="product_type:example"]
Displaying products based on multiple terms
To list products with multiple terms, you need to separate the terms using either a plus sign (AND) or a comma (OR). If you are selecting from several custom taxonomies, you need to add the taxonomy slug before each term.
The following example will display products with the product_type of coats or shoes:
[product_table columns="name,description,price" term="product_type:coats,shoes"]
The following example will display products with a product_type of coats and a product_status of trade:
[product_table columns="name,description,price" term="product_type:coats+product_status:trade"]
Displaying number-based taxonomy terms
By default, WooCommerce Product Table works with text-based custom taxonomy terms, e.g. ‘coats’ or ‘shoes’. If you are using numeric taxonomy terms, then you need to add
numeric_terms="true" to the shortcode.
[product_table term="product_group:45" numeric_terms="true"]
cf option lets you select products based on a custom field value. Enter it in the following format:
cf="<field name>:<field value>".
As with the above options, you can enter one custom field to check, or several. You can separate them using a comma or a plus sign (see categories or tags above for more details).
For example, if you wanted to display cars which are either blue OR are Audis, you would use:
[product_table columns="name,description" cf="color:blue,make:audi"]
However if you wanted to select the blue Audis (i.e. color = blue AND make = audi) you would use:
[product_table columns="name,description" cf="color:blue+make:audi"]
Custom fields added using the Toolset Types plugin
If you’re using Toolset Types to create your custom fields, then you need slightly different syntax to display them in the product table.
wpcf- to the start of the custom field name, so if you create a custom field called ‘color’ with a value of ‘blue’ then the correct syntax will be
wpcf-color:blue. This means that if you want to create a table displaying blue products then you would need to add it as follows:
Display products based on when they were published
The following three options control which posts are displayed based on the date they were published.
year option lets you display products published in a specific year only. For example:
month option lets you display products published in a specific month only. You should use a number here between 1 and 12.
For more fine-grained control, you can combine this with the year or day options. For example:
[product_table year="2015" month="11"]
day option lets you display products published on a specific day of the month. You should use a number between 1 and 31.
You can combine this with the year or month options, for example:
[product_table month="4" day="25"]
status option controls which products are displayed based on their post status. The default status is “publish”. The other options are ‘draft’, ‘pending’, ‘future’, ‘private’ or ‘any’. Pending products are those pending a review. Future posts are those scheduled to be published at a future date. Private posts have their visibility set to Private which means they can only be viewed by the original author or other administrators.
You can also use a list of post statuses separated by commas, for example:
[product_table columns="name,price,add-to-cart" status="publish,draft"]
Exclude products by ID
exclude option lets you exclude products from the table based on the ID. You can enter one ID or a list or IDs.
Example excluding two specific products:
Include products by ID
include option can be used to show only specific products in your table. You can enter one product ID or a list of IDs.
Please note that
exclude are mutually exclusive – if you set one, the other will be ignored.
Example displaying four specific products only:
exclude_category option is used to exclude entire categories of products from your table. You can use category IDs or slugs, and it can be one category or a comma-separated list.
You can use the
term option to show featured products in the table. These are products that you have marked a ‘Featured’ on the Add/Edit Product screen. Simply add
term="product_visibility:featured" to the product table shortcode. (Note: This only works in WooCommerce version 3 and above.)
List variations for a specific product only
You may wish to create a product table listing the variations for a specific product. For example, this might be useful if you wanted to add a table of variations to the single product page for each product.
[product_table include="54150" variations="separate" columns="name,price,stock,add-to-cart" cart_button="checkbox" show_quantity="true" links="none" page_length="false" search_box="false" reset_button="false" totals="false"]
Hide out of stock products
To hide out of stock products from the table, you can tick the ‘Hide out of stock items from the catalog’ box in the WooCommerce settings. Find this option at /wp-admin/admin.php?page=wc-settings&tab=products§ion=inventory.
Show out of stock products
You can use the
term option to create a table that only shows out of stock products. Simply add
term="product_visibility:outofstock" to the product table shortcode. (Note: This only works in WooCommerce version 3 and above.)