How to remove the woocommerce default sorting drop-down categories.

If you want to remove some default sorting categories in the drop down filter then kindly follow the below steps.

Step 1

Open the file in this path /wp-content/themes/theme-folder/functions.php using some editor like DreamWeaver and scroll to the end of the file then append the below code,

Note : If you have used the child theme then get into the file path /wp-content/themes/childtheme-folder/functions.php.

Here we have attached the code for disable the all category, you can comment or remove the desire category,

function my_woocommerce_catalog_orderby( $orderby ) {
unset($orderby["popularity"]);
unset($orderby["rating"]);
unset($orderby["date"]);
unset($orderby["price"]);
unset($orderby["price-desc"]);
return $orderby;
}
add_filter( "woocommerce_catalog_orderby", "my_woocommerce_catalog_orderby", 20 );

For example if you want to hide a sort by popularity and sort by average ratings category,

function my_woocommerce_catalog_orderby( $orderby )
{
unset($orderby["popularity"]);
unset($orderby["rating"]);
return $orderby;
}
add_filter( "woocommerce_catalog_orderby", "my_woocommerce_catalog_orderby", 20 );

Rate This Article

(5 out of 13 people found this article helpful)

Leave A Comment?

This site uses Akismet to reduce spam. Learn how your comment data is processed.