php - Comparing meta_query with array does not work -
in database have following entry @ order_products:
a:1:{i:0;s:6:"1234";}
i try show orders 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;
with
compare => 'like'
it working if there more single "1234" product, these orders showing (for example product 1234, 1235 , 1256). want show if alone.
i think issue comparing array.
compare => "="
is there way compare single item array "=" ?
give value numeric form 'value' => array ( 79, 200, 124) example below
//note check relation comment , 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' ) )
any problem welcome.
Comments
Post a Comment