I am trying to figure out sorting posts with prices in one meta query, so the posts without prices are shown last, when ordered by ASC and not first.
Right now I am temporarily not showing posts without prices but it can’t be left like that.
$args = array( 'post_type' => 'inwestycja', 'post_status' => 'publish', 'meta_key' => 'price', 'meta_type' => 'NUMERIC', 'orderby' => 'meta_value_num', 'meta_value' => 1, 'meta_compare' => '>', 'order' => 'ASC', 'tax_query' => array( array ( 'taxonomy' => 'inwestycje', 'field' => 'id', 'terms' => $tax->term_id, ) ), 'posts_per_page' => 24, 'paged' => $paged, );
Any suggestion how to approach such a problem, without extra work on front end. Extra switches for empty posts with empty prices and so on. Automatic solution 🙂
Problem is that ASC sorts posts with no price as cheapest, so they are first 🙂