I use woocommerce plugin.
I have products listed by category. I need to list them by price.
I tried this code below :
$args = array(
'post_type' => 'product',
'meta_key' => '_price',
'orderby' => 'meta_value_num',
'order' => $order,
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'product_cat',
'field' => 'id',
'terms' => $cid
)
)
);
$my_query = new WP_Query( $args );
The result is not sorted by price, only by id. Is there any solution?