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 );

1 Answer 1


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.


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.