How to change woocommerce "sort by" text?

by edmond_brakus , in category: PHP CMS , a month ago

How to change woocommerce "sort by" text?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by aniya.jaskolski , a month ago

@edmond_brakus 

To change the "Sort by" text in WooCommerce, you can use the following code snippet in your theme's functions.php file:

1
2
3
4
5
6
function custom_woocommerce_catalog_orderby($sortby){
    $sortby['menu_order'] = 'Custom Sorting';
    return $sortby;
}

add_filter('woocommerce_catalog_orderby', 'custom_woocommerce_catalog_orderby');


In this code snippet, we are using the woocommerce_catalog_orderby filter to modify the options displayed in the "Sort by" dropdown on the shop page. Replace 'Custom Sorting' with the text you want to display instead of "Sort by".


After adding this code snippet to your theme's functions.php file, the "Sort by" text should be changed to your desired text on the shop page in WooCommerce.