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.
Please note that the options on this page can only be added directly to the
[product_table] shortcode, and do not appear on the plugin settings page. This lets you add multiple product tables to your website, each showing different products.
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:
Tip: If you want to use product tables for all your categories, then you can modify the category archive template to automatically use the product table layout on your WooCommerce category pages. This is easier than creating a separate page for each category, each with a different shortcode.
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.
tag 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”:
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:
If you wanted to list posts with either of two values from the same custom field (for example cars that are blue or red) then you would use:
However if you wanted to select the blue Audis (i.e. color = blue AND make = audi) you would use:
Custom fields added using the Toolset plugin
If you’re using Toolset 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:
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"]
Please note that it is not possible to use the term option to list products from two different taxonomies. For example, the following shortcode will NOT work:
[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"]
You can also use the term option to list products with a specific attribute value. Add
pa_ before the attribute name, followed by a colon and the attribute term(s).
For example, this shortcode will list products with a ‘color’ attribute of ‘black’:
- You can only use this method to list products based on their global attributes, which you create under Products → Attributes in the WordPress admin and then select for each product. It’s not possible to list products with custom attributes that are created directly on the Add/Edit Product screen.
- This option works by looking at which attributes are attached to each product. If you are using it to display variable products, then it will list all variations for the product, and not just the ones that have these attributes. If you’re using the separate variations option and want to create a table listing specific variations based on their attributes, then the only way to do this is to use option 2 of these instructions to link to a pre-filtered table based on those attributes.
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.
Products previously ordered by current user
You can use WooCommerce Product Table to list products that the current logged in user has previously purchased. Simply add
user_products="true" to the shortcode, for example:
When using this option, we generally recommend adding the table to a page that is only visible to logged in users. Our tutorial contains advice on how to add it to the WooCommerce Account page or to another hidden page.
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/variations
There are 2 ways to hide out of stock products or variations from the table. Use the first method if you want to hide out of stock products globally throughout your store; or the second method to create a product table that only shows ‘in stock’ products without hiding them from the rest of your store.
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.
WooCommerce comes with a custom field meta key that you can use to only show ‘In Stock’ products in the product table. To do this, add
cf="_stock_status:instock" to your product table shortcode.
Please note: Method 2 only works for simple products, and not out of stock variations.
Show out of stock products/variations
You can use the
term option to create a table that only shows out of stock products or variations. Simply add
term="product_visibility:outofstock" to the product table shortcode. (Note: This only works in WooCommerce version 3 and above.)
Note: This will only work if your general WooCommerce settings are set to display out of stock products. If you want to hide out of stock products from your main product tables so that you can create a different table listing out of stock products, then you should also see the advice in the previous section instead of hiding out of stock products globally via the WooCommerce inventory settings.
Show backorder products/variations
Products and variations with a stock status of ‘On backorder’ are treated in the same way as ‘In Stock’ products. It’s not possible to display them separately from products that are in stock. Please see our separate article on backorder products and variations.
Show bestselling or popular products
It’s also possible to create product tables listing your most popular or bestselling products, based on the number of sales. Please see our full tutorial on how to do this.
Show ‘on sale’ products
Unfortunately there’s no automatic way to show discounted/sale products in the table. This is because WooCommerce doesn’t store this information as a taxonomy or custom field that you can display using WooCommerce Product Table.
Here are two suggested workarounds:
- Mark your reduced price products as ‘featured’ and use these instructions to list them in the table.
- If you want to use featured products for something else, then you could also create a custom taxonomy (instructions here) and use it to tag products that are on sale. You can then use the term option to show on sale products only.
Show products with a specific price
WooCommerce Product Table doesn’t have a feature to list products based on price. However, you can achieve something similar by using the price filter that comes with the plugin.
Instead of linking to a normal page with a product table, you need to link to the URL of a table that is pre-filtered by price. There are instructions on how to do this in this article.