WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i've saved and array of 'open days' as a serialised array in a meta value.

I was hoping i could then just search this field for the selected dates but i can't seem to create a match.

serialised = a:2:{i:0;s:10:"2011-09-16";i:1;s:10:"2011-09-17";} ; // two open dates

and was trying this and some variation without luck ;

$values_serialized = serialize(array('2011-09-16')); // need to serialise???

$args =  array ('meta_query' => array( 
    array( 'key'=>'v-openDays', 'value'=>$values_serialized,'compare'=>'IN' ) 
// IN or LIKE?

will also be searching for multiple days but need to get one working first! Help appreciated, Dc

share|improve this question
up vote 2 down vote accepted

Don't serialize the search value, just use 'value' => '2011-09-16' 'compare' => 'LIKE'.

Otherwise you're essentially looking for;


Which of course doesn't actually match anywhere in;

share|improve this answer
yeh - finally figured out that much and also IN had to be LIKE. Cheers! – daniel Crabbe Jun 27 '11 at 17:03
@daniel nice one - updated answer for 'correctness' ;) – TheDeadMedic Jun 27 '11 at 18:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.