Order by meta value or date?

Question

Got a custom field called startDate but its only on a few events. I was wondering if it isn’t set for a post I could use post_date to generate the posts list?

// if meta_key _postmeta.startDate isn't set get the rest by posts.post_date

query_posts(
    array(
        array(
            'posts_per_page' => 10,
            'meta_key' => 'startDate',
            'meta_value' => date('Y-m-d'),
            'meta_compare' => '<',
            'orderby' => 'meta_value',
            'order' => 'ASC'
        ), 
        array(
            'meta_key' => 'post_date',
            'meta_value' => date('Y-m-d'),
            'meta_compare' => '<'
        )
    )
);
0
v3nt 2 months 0 Answers 12 views 0

Leave an answer