I have spend hours yesterday solving my problem but it didn’t work.
I want to sort my product of a specific brand on price (low to high), all other sorting options work fine title, id, etc.. But my self declared $arg regular_price won’t work.
I have added this code to functions.php in my theme map:
add_filter( 'woocommerce_shortcode_products_query', 'woocommerce_shortcode_products_orderby' );
function woocommerce_shortcode_products_orderby( $args )
{ $standard_array = array('menu_order','title','date','rand','id');
if( isset( $args['orderby'] ) && !in_array( $args['orderby'], $standard_array ) )
{ $args['regular_price'] = $args['orderby'];
$args['orderby'] = 'meta_value_num'; }
return $args;}
And I use this shortcode :
[product_attribute attribute="merk" filter="bait footwear" per_page="80" columns="4" orderby="regular_price" order="asc"]
The result is here:
http://vintagekledingwinkel.nl/aanbiedingen/bait-footwear/
What am i missing?
Try this code:
And use below short code:
Let me know the output.