0

I have the below query which isn't returning anything. The query is meant to look for the date (2014-03-01) that is in the array, which it is.

Any ideas? Or would I need to use a custom SQL query?

// the income_dates array looks like this
// a:3:{i:0;s:10:"2014-02-01";i:1;s:10:"2014-03-01";i:2;s:10:"2014-03-29";}

$args = array(
    'post_type' => 'income',
    'meta_query' => array( 
        array(
            'key' => 'income_dates',
            'value' => "2014-02-01",
            'type'  => 'date',
            'compare' => 'IN'
        ),
    )
);
2
  • Do you want to use the complete array in the meta_query or just a single element from the array as above? Feb 1, 2014 at 6:08
  • Just a single element
    – user537137
    Feb 1, 2014 at 8:18

1 Answer 1

0

If you store the meta as a serialized array, you should do meta query like this:

$args = array(
    'post_type' => 'income',
    'meta_query' => array( 
        array(
            'key' => 'income_dates',
            'value' => "2014-02-01",
            'compare' => 'LIKE'
        ),
    )
); 
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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