WooCommerce: Change the Default Product Sorting in Shop Page
In shop page the product sorting by default is set to Default, if you want to set it to Date (Sort by Latest) as on this example…
you need to piece of code in your functions.php
and now the product sorting is set to Sort by Latest. this is by latest product up to date.
add_action( 'woocommerce_default_catalog_orderby', 'custom_default_catalog_orderby' );
function custom_default_catalog_orderby( $sort_by ) {
/*
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)
*/
return 'date';
}
