A
A
Alex Kizyma2020-06-08 23:02:09
WordPress
Alex Kizyma, 2020-06-08 23:02:09

Why doesn't meta_query ACF work?

global $post;
$status = $_POST['status'] ? $_POST['status'] : '';

// var_dump($status); 
// array(3) { [0]=> string(7) "instock" [1]=> string(4) "sold" [2]=> string(8) "intheway" }

$cars = new WP_Query([
    'post_type' => $post_type,
    'post_status' => 'publish',
    'meta_query' => [
                   [
                       'key'     => 'position_car',
                       'value'   => $status,
                       'compare' => 'NOT IN',
                   ],
            ]
  ]);

    // show
    if ($cars->have_posts()):
    while ($cars->have_posts()): $cars->the_post();
    
      the_title();
  
    endwhile;
    endif;
  
    wp_reset_postdata();
    wp_die();

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question