WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

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 have a custom field value that is an array and it has date as one of the values:


I'm trying to sort posts with this date but I'm having trouble doing it.

Here is my query:

   $args = array (
            'showposts' => -1,
            'post_type' => 'project',
            'orderby' => 'meta_value',
            'order' => 'ASC',
            'meta_query'  => array(
                        'key' => 'date',
                        'value' => date('m/d/Y'),
                        'compare' => '>=',
                        'type' => 'DATETIME',
            'cat' => $cat_id);
        $posts = get_posts( $args );
share|improve this question
up vote 1 down vote accepted

Sadly you can't.

You can't query based on serialized data and since you store the data in an array it is saved as serialized.

you should use a separate row for each field you want to query / sort based on.

I asked this same question about two years ago.

share|improve this answer
Thank you, i need to do it other way – raaaa Mar 10 '13 at 15:04

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.