Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save runezero/82a6c68c2c75fe50fe9f7cdfe89f43aa to your computer and use it in GitHub Desktop.

Select an option

Save runezero/82a6c68c2c75fe50fe9f7cdfe89f43aa to your computer and use it in GitHub Desktop.
[Force shop sorting] Set the WooCommerce sorting to a parameter if a parameter is set #woocommerce
add_filter('woocommerce_default_catalog_orderby', 'default_catalog_orderby');
function default_catalog_orderby( $sort_by ) {
if(count($_GET) < 1 || isset($_GET['s']) && count($_GET) == 1){
return 'date';
}
return $sort_by;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment