Voeg deze code toe aan de functions.php van je thema of Code Snippets.


//Adding Alphabetical sorting option to shop and product settings pages
function alphabetical_shop_ordering( $sort_args ) {
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
if ( 'alphabetical' == $orderby_value ) {
$sort_args['orderby'] = 'title';
$sort_args['order'] = 'asc';
$sort_args['meta_key'] = '';
}
return $sort_args;
}
add_filter( 'woocommerce_get_catalog_ordering_args', 'alphabetical_shop_ordering' );

function custom_wc_catalog_orderby( $sortby ) {
$sortby['alphabetical'] = 'Sort by Name: Alphabetical';
return $sortby;
}
add_filter( 'woocommerce_default_catalog_orderby_options', 'custom_wc_catalog_orderby' );
add_filter( 'woocommerce_catalog_orderby', 'custom_wc_catalog_orderby' );