Change Default Product Sorting

The default WooCommerce sorting is by “menu order”, which means manually and if a manual product order is not set, the product are going to be displayed alphabetically.

Before we continue, let me show you how to sort WooCommerce products manually, maybe it is just what you need.

Go to WordPress admin, All Products page, and there click Sorting tab. After that just use drag and drop.

Reorder WooCommerce products manually in WordPress admin

The second way is to set menu_order value manually in the product data metabox.

How to change product ordering position in WooCommerce
If you set -1, most likely this product will be displayed first.

Now let me show you how to change this default product sorting “menu_order + title” to something else. It can be done in WooCommerce settings as well or even with the filter hook.

Change the Product Sorting in WooCommerce Settings

If you have WooCommerce 3.2.6 or below, you can go to Settings > Products > Display tab and change the default sorting there. Otherwise, if your WooCommerce version is 3.3.0 and above, you couldn’t find Display tab, because it was completely moved to Customizer.

So, go to Appearance > Customize > WooCommerce > Product Catalog. And here we are.

Since WooCommerce 3.3 you can find product Display settings and the default sorting option in customizer

You might see on the screenshot above that when we change the value of default product sorting in customizer, it also changes in product sorting dropdown above the product list. If you with to remove it from there, this tutorial is for you.

Using Hook to Change the Default Product Ordering in the Code

As simple as to insert the below code into your current theme functions.php file.

add_filter( 'woocommerce_default_catalog_orderby', 'misha_default_catalog_orderby' );

function misha_default_catalog_orderby( $sort_by ) {
	return 'date';
}

Possible values are:

It is also possible to create a custom product ordering, for example to display products in stock first.

Change the Default Ordering only for a Certain Category

Sometimes you may need it too. Actually you can use the same code, but just add a condition like is_product_category( 'category-slug' ). Example:

add_filter( 'woocommerce_default_catalog_orderby', 'misha_catalog_orderby_for_category' );

function misha_catalog_orderby_for_category( $sort_by ) {
	if( ! is_product_category( 'uncategorized' ) ) { 
		return $sort_by; // no changes for any page except Uncategorized
	}
	return 'date';
}
Misha Rudrastyh

Misha Rudrastyh

Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.

Need some developer help? Contact me

Follow me on X