
在這邊想要刪除掉預設排序裡面的 依平均評分
先到funcion.php輸入兩段程式碼
#從商店模板中移除 "默認排序"之中的"依照平均評分"
function wizhi_remove_default_sorting_option( $catalog_orderby_options ) {
unset( $catalog_orderby_options['rating'] );
return $catalog_orderby_options;
}
add_filter('woocommerce_catalog_orderby','wizhi_remove_default_sorting_option');
#移除後台设置中的依照評分過濾選項
function wizhi_remove_default_sorting_from_settings( $options ) {
unset( $options['menu_order'] );
return $options;
}
add_filter('woocommerce_default_catalog_orderby_options','wizhi_remove_default_sorting_from_settings');

這樣就大功告成

這邊是woocommerce默認排序方式的程式碼
array(
'menu_order' => __( 'Default sorting', 'woocommerce' ),
'popularity' => __( 'Sort by popularity', 'woocommerce' ),
'rating' => __( 'Sort by average rating', 'woocommerce' ),
'date' => __( 'Sort by newness', 'woocommerce' ),
'price' => __( 'Sort by price: low to high', 'woocommerce' ),
'price-desc' => __( 'Sort by price: high to low', 'woocommerce' )
)
如果要取消哪一個 就在上面function.php的程式碼
unset掉那個就好了
像剛剛是移除掉平均評分 就是rating
unset( $catalog_orderby_options['rating'] );
如果想移除掉依照熱銷度
就是
unset( $catalog_orderby_options['popularity'] );
以下是移除所有排序選項
//移除所有排序
add_filter( 'woocommerce_catalog_orderby', 'misha_remove_default_sorting_options' );
function misha_remove_default_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;
}