sorting - Wordpress failing to sort and filter in same wp_query with meta values using relational operators -
i trying implement filter , sort scheme woo-commerce products in wordpress. there 2 prices in scheme (buy , rent) below argument array:
$args = array( "post_type" => "product", 'orderby' => 'meta_value_num', // order cost 'meta_key' => '_regular_price', 'order'=>'asc', 'meta_query' => array( 'relation' => 'and', array( // getting cost values greater 1 in ordering 'key' => '_regular_price', 'value' => 0, 'compare'=>'>' ), array( "relation" => 'or', array( "key" => array('_regular_price','rent_price'), "value" => array(1, 1000), "compare" => 'between', "type" => 'decimal' ), array( "key" => array('_regular_price','rent_price'), "value" => array(5000, 10000), "compare" => 'between', "type" => 'decimal' ), )
), );
if remove order clause works ok, or else if remove filter clause works fine. both of them wont work.
here conditions looking implement:
order purchase cost or rent cost (no cost range selected & cost > 0) filter products between cost range (single cost range or multiple) both of above together wordpress sorting meta wp-query meta-key
No comments:
Post a Comment