Created
November 2, 2017 12:47
-
-
Save laurelstreng/880d4b76367a7602e6221b80bf936f7a to your computer and use it in GitHub Desktop.
Woocommerce remove items from sorting dropdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Woocommerce Sorting Dropdown | |
* @param $orderby | |
* @return mixed | |
* | |
* Remove items from sorting dropdown | |
*/ | |
function ls_woocommerce_catalog_orderby( $orderby ) { | |
// We still need to add the functionality that actually does the sorting | |
$orderby['oldest_to_recent'] = __( 'Sort by date: oldest to newest', 'woocommerce' ); | |
// Change the default "Sort by newness" to "Sort by date: newest to oldest" | |
$orderby["date"] = __('Sort by date: newest to oldest', 'woocommerce'); | |
// Remove rating, price & price-desc | |
unset($orderby["rating"]); | |
unset($orderby["price"]); | |
unset($orderby["price-desc"]); | |
return $orderby; | |
} | |
add_filter( 'woocommerce_catalog_orderby', 'ls_woocommerce_catalog_orderby', 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment