function woocommerce_shop_ordering_add_option( $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['meta_key'] = 'property_priority'; $sort_args['orderby'] = 'meta_value'; $sort_args['order'] = 'DESC'; } return $sort_args; } add_filter( 'woocommerce_get_catalog_ordering_args', 'woocommerce_shop_ordering_add_option' ); function woocommerce_catalog_orderby_add_option( $sortby ) { $sortby['alphabetical'] = 'Sort by STC'; return $sortby; } add_filter( 'woocommerce_default_catalog_orderby_options', 'woocommerce_catalog_orderby_add_option' ); add_filter( 'woocommerce_catalog_orderby', 'woocommerce_catalog_orderby_add_option' );
Leave a Reply