In my database I have the following entry at order_products:
I try to show only orders with the product_id 1234:
$orders = array(
'post_type' => 'orders',
'year' => $year,
'monthnum' => $month,
'day' => $day_minus,
'meta_query' => array (
'key' => 'order_status',
'value' => array( 'bill', 'back', 'pay', 'completed' ),
'compare' => 'IN'
'key' => 'order_products',
'value' => array('1234'),
'compare' => '='
$the_query = new WP_Query( $orders );
$total_orders = $the_query->found_posts;
compare => 'LIKE'
it is working but if there are more than the single "1234" product, these orders will showing as well (for example with product 1234, 1235 and 1256). But I only want to show it if it is alone.
I think the issue is with comparing the array.
compare => "="
Is there a way to compare a single item from an array with "=" ?