wp query – Sort by price woocommerce by ID post_meta
There is an additional field in Posts (id_product), when using WP_Query I want to sort posts by meta _price (id_product).
How do I do this?
If I try to do so:
$query->set( 'meta_key', '_price' ); $query->set( 'orderby', 'meta_value' ); $query->set( 'order', 'desc');
Sorting is done not by _price, but by the number specified in post_meta