1. Knowledge Base
  2. WooCommerce Product Table
  3. Product Table Options

Product table sort options

WooCommerce Product Table comes with 2 options for sorting the table when it first loads. Once the table has loaded, customers can click on a column heading to sort by that column.

Sort by

The sort_by option controls which column the table is sorted by when first displayed.

If not specified, the WooCommerce default product ordering is used. This can be found under the WooCommerce > Settings > Products > Display menu.

Sort options

You can order by any of the following:

  • name – sort by product name
  • menu_order – sort by the order listed in the Products menu when in the “Sorting” view
  • id – sort by product ID
  • sku – sort by product SKU
  • cf:[field] – sort by custom field (replacing [field] with your custom field name)
  • price – sort by price
  • popularity – sort by total number of sales (see our tutorial on listing your bestselling products)
  • reviews – sort by average customer review
  • date – sort by the date the product was first added to your store
  • modified – sort by the date the product was last updated
  • rand – apply random ordering

Extra sort options for tables using “standard loading”

If your table is not using the lazy load option – e.g. [product_table lazy_load=false] – then you can also sort by any other column in your table. This includes short-description, description, categories, tags, stock and any attribute column. To sort by attribute you use att:[attribute] in the sort_by option in the shortcode, e.g:

[product_table lazy_load=false sort_by="att:color"]

How to set the default sorting

You can set this option globally on the plugin settings page, or directly in the shortcode for individual tables.

Examples:

  • Sort using keyword:  [product_table columns="name,tags,categories,price,add-to-cart" sort_by="rating"]
  • Sort using any column in table (when lazy load is disabled):  [product_table columns="sku,image,name,price,add-to-cart" sort_by="sku"]

Sort order

The sort_order option controls the direction in which the table is sorted. Use asc for ascending order or desc for descending order.

The defaults is desc for date sorting and asc for everything else. For example, if you wanted to alphabetize the table by listing items in alphabetical order, then the default will be correct.

You can set this option globally on the plugin settings page, or directly in the shortcode for individual tables.

Example:

  • [product_table columns="name,price,add-to-cart" sort_by="price" sort_order="desc"]

Can I sort by multiple columns?

No, this is not currently possible. The table can only be sorted by a single column.

Can I sort the table by number?

By default, the table is sorted alphabetically rather than numerically. This applies to all text-based columns including custom fields and taxonomies.

If you’re using custom fields or taxonomies to store numbers instead of text, then you may wish to sort the table in number order. There is no option for this, but you can achieve this by adding the numbers in a format that will make sense when ordered alphabetically. For example:

  • If you add numbers in the format 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and 11, then they will be sorted in the following order – 1, 10, 11, 2, 3, 4, etc. This does not look correct.
  • If you’re sorting by a custom field containing numbers 01, 02, 03, 04, 05, 06, 07, 08, 09, 10 and 11, then they will be sorted correctly both alphabetically and numerically.

Can I sort the table manually?

You can put the products displayed in the table in a certain order or manually set the order of the products listed/displayed in the table by using the menu_order sort option.

Using sort_by="menu_order" will sort by the order listed in your website’s WordPress Dashboard > Products > All Products – “Sorting” view, which you can easily rearrange manually, to be in the order that you wish to display in the product table, as shown:

How to change the order of the items in the filter dropdowns

Most of the filter dropdowns that you can add above the product table can only be sorted alphabetically. However, it is possible to control the order in which attributes are listed. This is done in WooCommerce rather than our plugin.

WooCommerce attributes list orderThe attributes in the filter dropdowns are sorted according to the ‘Default sort order’ set in Products > Attributes. If you hover over the Name column and click the Edit link, then you will see a page where you can set the ordering.

In the example screenshot, we’ve set the “Brand” attribute to be ordered by ‘Name’ (i.e. alphabetical). ​

If you use ‘Custom ordering’ then you can drag and drop the attributes into the correct order when you edit the ​terms for that attribute (click ‘Configure Terms’ from the Products > Attributes page).<

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

Related Articles