admin管理员组

文章数量:1390775

I am trying to query a custom post type that has a meta value (DATE) that are equal or greater than today. My issue is that some posts have the date stored in the "Ymd" format and others have "Y-m-dTg:i a".

This is what I currently have. It currently isn't ordering properly.

'posts_per_page'   => -1,
    'orderby'          => 'meta_value_num',
    'order'            => 'ASC',
    'post_type'        => 'funeral',
    'post_status'      => 'publish',
    'meta_query' => array(
        array(
            'relation' => 'OR',
            array(
                'key' => 'service_date',
                'value' => date('Ymd'),
                'compare' => '>=',
                'type' => 'DATE'
            ),
            array(
                'key' => 'service_date',
                'value' => date('Y-m-dTg:i a'),
                'compare' => '>=',
                'type' => 'DATE'
            )
        )
)

本文标签: meta querymetaquery check multiple date formats