首先,日期格式必须从大到小按降序排列,即年、月、日、时、分、秒等,否则MySQL无法在字段上查询或排序。在本例中,我使用年-月-日:
$today = date( \'Y-m-d\' );
$args = array(
\'post_type\' => \'vehicle\',
\'meta_query\' => array(
array(
\'key\' => \'end_date\',
\'value\' => $today,
\'compare\' => \'>=\',
\'type\' => \'DATE\'
)
)
):
$query = new WP_Query( $args );