Customize the Sorting Dropdown in WooCommerce

It would be great if there was a way to change the default sort by dropdown in WooCommerce on the shop page.

Right now the sorting drop down looks like this:
http://cld.wthms.co/OBgj

And I would very much like to be able to remove a couple of options (Sort by price: low to high & Sort by price: high to low). The final result should look something like this:
http://cld.wthms.co/NHVw

1 Answer
1

Actually, with a little digging this is quite easy to do. WooCommerce has already set up a filter so all you have to do it add a small snippet in your functions.php file.

// Modify the default WooCommerce orderby dropdown
//
// Options: menu_order, popularity, rating, date, price, price-desc
function my_woocommerce_catalog_orderby( $orderby ) {
    unset($orderby["price"]);
    unset($orderby["price-desc"]);
    return $orderby;
}
add_filter( "woocommerce_catalog_orderby", "my_woocommerce_catalog_orderby", 20 );

taken from: https://gist.github.com/BFTrick/5806726

In this example I’m removing price & price-desc but you can remove any of the options

Leave a Comment