Meta query with arrays
-
Hi Steve
Me again. Any idea if the values stored as an array (e.g. entered via a checkbox group) behave any differently in this plugin? If not, then it’s possibly my WordPress knowledge that’s lacking but either way, any idea how to use array values in a meta_query? i.e. as part of the args for a get_posts or WP_Query?
E.g. Here’s what I’m working with (the $args list is longer so have just included the relevant part):$args = array(
‘meta_query’ => array(
array(
‘key’ => ‘_slt_client_by_year’,
‘value’ => ‘2010’, // the values saved are 2010, 2011 etc
‘compare’ => ‘IN’,
)
)Essentially I’m trying to find out whether the year e.g. 2010 is one of the values saved in the custom field _slt_client_by_year
The meta_query certainly works with non-array values (by using compare=>”=”) but so far no success searching for a value within an array.
Hope I’ve explained that clearly enough.
Thanks for your help
Tim
- The topic ‘Meta query with arrays’ is closed to new replies.