Skip to content

Instantly share code, notes, and snippets.

@mikejolley
Created January 16, 2012 18:54
Show Gist options
  • Star 36 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save mikejolley/1622323 to your computer and use it in GitHub Desktop.
Save mikejolley/1622323 to your computer and use it in GitHub Desktop.
WooCommerce - Change default catalog sort order
/**
* This code should be added to functions.php of your theme
**/
add_filter('woocommerce_default_catalog_orderby', 'custom_default_catalog_orderby');
function custom_default_catalog_orderby() {
return 'date'; // Can also use title and price
}
@Hamidaraghi
Copy link

If you want the catalog ordering to still work properly you should wrap your code in something like:

function woocommerce_catalog_orderby( $args ) {
if(!$_GET['orderby']) {
$args['orderby'] = 'menu_order';
$args['order'] = 'asc';
}
return $args;
}

I was having a problem with a client wanting a specific order while also wanting the sorting to still function. This worked.

Thank you sir! 👍

@AngeloLazzari
Copy link

@hoaiphatcr YOU saved my day!!!! thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment