woocommerce change shop page default order

WooCommerce: Change Product Order On Shop Page

Change the default product ordering on your WooCommerce shop page with this handy code snippet.

https://gist.github.com/DeveloperWil/7ed168632a75e2d012506d6aef94ddcf

Sometimes you need to programatically change the default product ordering on the WooCommerce shop page, overriding the settings.

You can change the default ordering parameter to:

  • ‘menu_order’ – by the custom order first, then by product name (Default)
  • ‘popularity’ – by the number of sales
  • ‘rating’ – by the average rating
  • ‘date’ – recently added products will be displayed first
  • ‘price’ – the cheapest products will be displayed first
  • ‘price-desc’ – the most expensive first
  • ‘rand’ – in a random order

Where To Put The Code Snippet?

This code snippet should go in your active theme’s functions.php file.

Add it to the bottom of the file, before any closing ?> characters.

It’s always a good idea to take a backup of your functions.php file in case anything goes wrong – you can just copy the old code back in again.

Are You New To WooCommerce?

If you haven’t yet started to build an email list of your WooCommerce shop customers, now is the best time to get started.

Was this article helpful?
YesNo