I am working on Wordpress website and hit an obstacle when I tried to do the following query:
$args=array(
'post_type' => 'post',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'ad_info',
'value' => // check again with weight between 50 and 100,
'compare' => //compare operator,
),
)
);
the value of the key ad_info
is: Array ( [weight] => 48 [height] => 160)
and I want to check if the value of weight
in this array is between 50 and 100. Can anybody help me on this problem? Thanks
In mysql array values saved as strings, and it make problem for WP_Query filtering.
So best solution in this problem - change saving method to 2 keys:
ad_info_width and ad_info_height.
In that way you can use meta_query between compare.