将meta_query与数组进行比较不起作用


Comparing meta_query with array does not work

在我的数据库中,我在order_products有以下条目:

a:1:{i:0;s:6:"1234";}

我尝试仅显示product_id 1234 的订单:

$orders = array( 
    'post_type' => 'orders',
    'year' => $year,
    'monthnum' => $month,
    'day' => $day_minus,
'meta_query' => array (
            array (
                'key' => 'order_status',
                'value' => array( 'bill', 'back', 'pay', 'completed' ),
                'compare' => 'IN'
             ),
        array (
                'key' => 'order_products',
                'value' => array('1234'),
                'compare' => '='
            )
        )
  ); 
$the_query = new WP_Query( $orders );
$total_orders = $the_query->found_posts;

compare => 'LIKE' 

它正在工作,但如果有多个"1234"产品,这些订单也会显示(例如产品 1234、1235 和 1256)。但我只想在它独自一人的情况下展示它。

我认为问题在于比较数组。

compare => "=" 

有没有办法将数组中的单个项目与"="进行比较?

将值作为数字形式给出 'value' =>数组 ( 79, 200, 124) 下面的示例

 //Note check relation with comment and uncomment form
 $args => array(
'relation' => 'AND',   
array (
            'key' => 'order_status',
            'value' => array( 'bill', 'back', 'pay', 'completed' ),
            'compare' => 'IN'
   ),
array(
    'key' => 'order_products',
    'value' => array ( 79, 200, 124)
    'compare' => '=',
    'type' => 'NUMERIC'
) )

任何问题欢迎。