In WP there is an arbitrary top_partner (true/false) field top_partner (true/false) , I want all the records on the page to be sorted by this field, if true then these records are at the top, if false then the records are at the bottom.

 $query = new WP_Query(array( 'post_type' => 'partner', 'posts_per_page' => -1, 'meta_key'=> 'top_partner', 'orderby' => 'meta_value', 'order' => 'DESC', 'tax_query' => array( array( 'taxonomy' => 'partner-city', 'field' => 'term_id', 'terms' => $category->term_id, //'operator'=> 'NOT IN' ) ) ) ); $posts = $cat = array(); while ($query->have_posts()) { $query->the_post(); //the_post(); $post = $query->post; //$taxonomies = wp_get_post_categories($post -> ID); print_r($post); exit; $categories = get_the_terms($post -> ID, 'partner-city'); if(count($categories) > 0){ foreach ($categories as $key => $value) { if($value->parent==$category->term_id || $value->term_id==$category->term_id) $posts[$value->name][] = $post; } }else $posts[$category->name][] = $post; } 

but this way I only see entries in which top_partner in labor. What needs to be changed in order to display the rest of the records? enter image description here

    1 answer 1

     $query = new WP_Query(array( 'post_type' => 'partner', 'posts_per_page' => -1, 'meta_key'=> 'top_partner', 'orderby' => 'meta_value', 'order' => 'DESC', 'meta_query' => array( array( 'key' => 'top_partner', 'value' => array(true, false), 'type' => 'BOOLEAN', ), ) 'tax_query' => array( array( 'taxonomy' => 'partner-city', 'field' => 'term_id', 'terms' => $category->term_id, //'operator'=> 'NOT IN' ) ) ) ); 
    • changed, but it did not help - Anton Kucenko
    • @AntonKucenko brought the same thing without false or something else and in what order? - Mike Foxtech am
    • did the same thing without false, did according to the documentation, I don’t understand why it doesn’t work - Anton Kucenko
    • @AntonKucenko if it is acf then you are right, the reason is something else - Mike Foxtech