Adding product tables to the category archive template
While WooCommerce Product Table is primarily designed to be used on standard WordPress pages, it can also be used on product category/archive pages by overwriting the product archive template in your theme. This will allow you to automatically display product tables when people view a category page, instead of the usual category layout.
How to add product tables to category archives
First create a folder called “woocommerce” in your theme or child theme (if it doesn’t already exist). See here for details: https://docs.woocommerce.com/document/template-structure.
Next, download archive-product.php by clicking the link and then upload it to the “woocommerce” folder. E.g:
You should then see product tables on your category pages, displaying products from the correct category.
If you inspect this template file, you’ll see on line 59 there is an
$args array which is passed to the [product_table] shortcode. In this example template, only the
columns option is set, but you can add more shortcode options to this array as required. For example, if you wanted to add the
sort_by option you would do:
$args = array( 'columns' => 'image,name,price,add-to-cart', 'sort_by' => 'name' );
Add / edit more shortcode options to suit your requirements (e.g. choosing your columns, setting search filters, etc. – please see our article on Creating Product Tables for instructions).
Using filter widgets on product category archives
WooCommerce Product Table comes with its own set of product filter widgets which you can add to a widgetized area such as a sidebar. These only work for product tables on normal pages and posts. They do NOT work for product tables that have been added to the category archive template.
To use filter widgets on category archives, you need to use the built-in WooCommerce filter widgets instead of the dedicated product table widgets. You can find these in Appearance > Widgets. They start with ‘WooCommerce’ instead of ‘Product Table’ (see screenshot).
Can I use a different shortcode for each category?
The above instructions assume that you’ll have the same shortcode for each category. To dynamically use different shortcodes depending on the current category, you would need to do some extra custom coding.
This is outside the scope of our standard plugin support. If you don’t know how to do the required coding, then we recommend that you post a job on Codeable where one of their WordPress experts can quote for the work. Alternatively, get in touch if you’d like a quote from our plugin customisations service.