Order post witch have custom fields first and all the other after
-
Hello I’m trying to display my posts based on a custom field value first and if my posts doesn’t have any custom field display them after.
ex :
first display the posts witch have a custum field value (meta_value_num ASC)
post1 > key = 1
post2 > key = 2
post3 > key = 3
after display all the other width custom field empty (alphabetical ASC)
post5 > key = empty
post6 > key = empty
post7 > key = empty
…$args = array ( 'post_type' => 'sellers', 'tax_query' => array( array( 'taxonomy' => 'city', 'field' => 'slug', 'terms' => $term_slug, ) ), 'meta_query'=> array( 'relation' => 'OR', array( //if key exclusive is not empty 'key' => 'exclusive', 'value' => '1', 'compare' => '>=', 'meta_type' => 'NUMERIC', ), array( //if key exclusive is empty 'key' => 'exclusive', 'value' => '1', 'compare' => 'NOT EXISTS' ) ), 'meta_key' => 'exclusive', 'orderby' => 'meta_value_num title', 'order' => 'ASC DESC', );
Can you help me please ?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Order post witch have custom fields first and all the other after’ is closed to new replies.