
You have a need to delete, rename, change the position of the sorting feature in WooCommerce. This article will walk you through all about that feature.
Clear sort options

To remove the options, I will use the WooCommerce filter hook woocommerce_catalog_orderby . Please add this code below to the file functions.php .
add_filter( 'woocommerce_catalog_orderby', 'hk_remove_sorting_options' );
function hk_remove_sorting_options( $options ){
unset( $options[ 'popularity' ] );
//unset( $options[ 'menu_order' ] );
//unset( $options[ 'rating' ] );
//unset( $options[ 'date' ] );
//unset( $options[ 'price' ] );
//unset( $options[ 'price-desc' ] );
return $options;
}
The above code is also quite clear. To remove the value according to your needs, open the comment code by removing the // character .
-
popularity: Popularity -
menu_order: Default value -
rating: Rating Score -
date: Latest -
price: Low to high price -
price-desc: High to low price
Rename sort options
In this part, I also use the same WooCommerce hook as above, hook woocommerce_catalog_orderby . Take a look at my code below.
add_filter( 'woocommerce_catalog_orderby', 'hk_rename_sorting_options' );
function hk_rename_sorting_options( $options ){
$options[ 'price' ] = 'Giá thấp lên cao nè';
return $options;
}
Similar to the above, you can add your own changes using the options popularity , menu_order , rating , date , price , price-desc .
This is the friend I achieved after pasting the above code into the functions.php file .

Change the order of sort options
To change the order of the sort options, what I need to do is redefine the WooCommerce array variable.
add_filter( 'woocommerce_catalog_orderby', 'hk_change_sorting_options_order', 5 );
function hk_change_sorting_options_order( $options ){
$options = array(
'menu_order' => __( 'Default sorting', 'woocommerce' ),
'price' => __( 'Sort by price: low to high', 'woocommerce' ),
'date' => __( 'Sort by latest', 'woocommerce' ),
'popularity' => __( 'Sort by popularity', 'woocommerce' ),
'rating' => __('Sort by average rating', 'woocommerce' ),
);
return $options;
}
Because in this case, I’m redefining the WooCommerce variable. So more than just sorting, you can delete or rename the options here.
Epilogue
I hope the above article will partly assist you better in changing the website interface according to your needs.
If this article was helpful and saved your time, please help me share it. Also if you are interested in similar topics, read other WordPress Tips articles and follow Fanpage so you don’t miss new posts from me.

