Skip to main content
Articles

Using a Hook to Change the Default Ordering in WooCommerce

As simple as inserting 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:

  • menu_order (Default) – by the custom order first, then by product name
  • popularity – by the number of sales
  • rating – by the average rating
  • date – recently added products will be displayed first
  • price – cheapest products will be displayed first
  • price-desc – the most expensive first
  • rand – in a random order (read also how to retain pagination in this case)