Skip to content

Instantly share code, notes, and snippets.

@BFTrick
Last active October 19, 2022 10:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BFTrick/97276c11efc6804c913bf219506fdbab to your computer and use it in GitHub Desktop.
Save BFTrick/97276c11efc6804c913bf219506fdbab to your computer and use it in GitHub Desktop.
A function that modifies the default WooCommerce orderby dropdown. You can put this snippet in your functions.php file.
<?php
// Modify the default WooCommerce orderby dropdown
//
// Options: menu_order, popularity, rating, date, price, price-desc
// In this example I'm changing the default "Sort by newness" to "Sort by date: newest to oldest"
function patricks_woocommerce_catalog_orderby( $orderby ) {
$orderby["date"] = __('Sort by date: newest to oldest', 'woocommerce');
return $orderby;
}
add_filter( "woocommerce_catalog_orderby", "patricks_woocommerce_catalog_orderby", 20 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment