1. Home
  2. Knowledge Base
  3. WooCommerce Product Table
  4. FAQ

How to list 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.

There are two ways to control which products appear in the table:

  1. Display product tables on your store's built-in product listing pages, such as the Shop page, category archive template, tag archive template, and so on. We have a separate article about how to do that.
  2. Use a shortcode to list specific products anywhere on your site. There are shortcode options allowing you to display products by category, tag, and much more. These options are documented below.

Category

The 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:
[product_table category="courses,books"]

To display posts which are in the "courses" category and in the "featured" category, use:
[product_table category="courses+featured"]

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?

WooCommerce table specific product categories

2 tables, each displaying products from a different category

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

The 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":
[product_table tag="awesome"]

Example 2: Display products with any of the tags "cool", "awesome" or "good":
[product_table tag="cool,awesome,good"]

Example 3: Display products with all of the following tags: "cool", "awesome" and "good":
[product_table tag="cool+awesome+good"]

Custom field

The 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 cf="color:blue,make:audi"]

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:
[product_table cf="color:blue,color:red"]

However if you wanted to select the blue Audis (i.e. color = blue AND make = audi) you would use:
[product_table cf="color:blue+make:audi"]

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.

Toolset adds 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:
[product_table cf="wpcf-color:blue"]

Custom taxonomy term

The 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.

Example: [product_table term="product_group:45" numeric_terms="true"]

Attribute

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':

[product_table term="pa_color:black"]

Notes:

  • 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

The year option lets you display products published in a specific year only. For example:
[product_table year="2016"]

Month

The 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

The 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"]

Product status

The 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,buy" status="publish,draft"]

See also: How to automatically expire products and remove them from the table on a certain date.

Stock status

By default, WooCommerce Product Table lists products with any stock status. The stock option lets you display products based on their stock status. The available options are:

  • instock - Show in stock products.
  • outofstock- Show out of stock products.
  • onbackorder - Show products on backorder.
  • discontinued - Only available when using WooCommerce Product Table with the WooCommerce Discontinued Products plugin. Shows products which have been discontinued.

Example: [product_table stock="instock,onbackorder"]

Exclude products by ID

The 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:
[product_table exclude="23,78"]

Include products by ID

The 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 include and exclude are mutually exclusive – if you set one, the other will be ignored.

Example displaying four specific products only:
[product_table include="23,45,67,90"]

Exclude categories

The 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.

Example: [product_table exclude_category="3,6"]
Example: [product_table exclude_category="discontinued"]

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:

[product_table user_products="true"]

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.

Hidden products

WooCommerce itself has visibility settings which allow you to select whether each product appears in the shop and research results, or is hidden and can only be accessed directly via its URL.

If you'd like to show hidden products in the product table then you can enable the Show hidden products option on the settings page. For example, this is useful if you want to display certain products in the product table while hiding them from your main shop pages.

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.)

Example: [product_table term="product_visibility:featured"]

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.

You can do this by using the variations=separate and includes options, for example:

[product_table include="54150" variations="separate" columns="name,price,stock,buy" cart_button="checkbox" quantities="true" links="none" page_length="false" search_box="false" reset_button="false" totals="false"]

See this shortcode in action on this product on our demo site. We also have a separate article with more guidance on showing product tables on the single product page.

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.

Related Articles

If searching the knowledge base hasn't answered your question, please contact support.