How to change the sorting of products in WooCommerce

woo expert

As we have already seen, the default order of the product catalog in an online store created with WooCommerce is alphabetical order + custom order.

This WooCommerce dropdown to display products in different order has, by default, the following options:

  • Default
  • By popularity
  • By average rating
  • By latest
  • Sort by price: high to low
  • Sort by price: low to high

How to change the default order of WooCommerce products.

There are several ways to change the default order of the products, and we are going to see them all, including some that will surprise you.

How to change the order of products in WooCommerce administration.

The first thing we are going to see is how to order products, not for customers, but for the store managers, in the WooCommerce administration.

We have basically 2 ways to do it, one that you surely already know but does not bring you much, and another that will surprise you.

The first, and obvious one, is to simply click on a column in the product management screen and sort them by name, SKU, price, etc.

The problem with this sorting method is that the order is not saved, the next time you access this screen you will again have the products sorted in order of publication, from newest to oldest.

But there is a trick, and that is to simply change the publication date of the product, something that makes sense not to keep changing on blog posts but almost never matters for products in an online store.

So, simply change the publication date of the products you want to have first to a recent publication date and that’s it.

You can do this by using the quick edit from the product management screen or by opening the product editor, whichever you prefer.

But there is still more, and this other method surely you had not even realized that it has always been there.

I’m referring to the list of products from the “Sorting” tab.

It turns out that this list allows you to manually change the order of your products by dragging and dropping, and yes, the order will be saved, so you will always have a customized list of products there, in the order you need for your price changes or whatever, although it will not change the order of the products in the other tabs.

It’s a good way to have the products in the order you want without having to mess up the other tabs.

How to change the default order of products by customizing it

For customers, the easiest way to change the default order of products is from the WordPress customizer.

Go to AppearanceCustomizeWooCommerceProduct Catalog and change the order to the one you prefer.

As you can see, simple and available in any WordPress installation with WooCommerce, no matter the active theme.

How to change the default order of products using a code

If you prefer to use code to change the default order of the product catalog in the store, and thus prevent any user with permissions to modify it from the customizer you’ve come to the right place.

Simply add a function like this to the functions.php file of the active (child) theme or your customizer plugin:

/* Change default sorting */ add_filter('woocommerce_default_catalog_orderby', 'wphelp_product_sorting'); function wphelp_product_sorting( $sort_by ) { return 'price-desc'; //change sorting to from highest to lowest price }
Code language: PHP (php)

The only thing you have to change in the code is return value, you can choose between:

  • menu_order (default) – by custom order number plus product name alphabetically.
  • popularity – by the number of sales.
  • rating – by the average number of ratings.
  • date – Newly published products will be displayed first.
  • price – The cheapest products will be shown first.
  • price-desc – The most expensive products will be shown first.
  • rand – Random order in the catalog display.

How to change the default order of products in a given category using a code

A variation of the above code would be to change the default order only in certain category or categories.

Just add a condition with is_product_category( 'slug-category' ).

It would look like this:

/* Change default sorting add_filter('woocommerce_default_catalog_orderby', 'wphelp_category_sorting'); function wphelp_category_sorting( $sort_by ) { if( !is_product_category('shoes') ) { return $sort_by; //no change for other categories } return 'rating'; //Sort this category by ratings }

As you can see, there are many possibilities to customize the order of the products.

Another day we will see even more customization possibilities, which there are.

Click to rate this post!
[Total: 0 Average: 0]

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top Skip to content