假设您的日期格式正确,以便正确订购(yyyy-mm-dd),请添加meta_query
到您的参数:
$args = array(
\'post_type\' => array(\'basic_events\'),
\'order\' => \'ASC\',
\'orderby\' => \'meta_value_num\',
\'meta_key\' => \'date_of_event\',
\'paged\' => $paged,
\'meta_query\' => array(
array(
\'key\' => \'date_of_event\',
\'value\' => date( \'Y-m-d\', current_time( \'timestamp\' ) ),
\'compare\' => \'>\',
\'type\' => \'DATE\'
)
)
);
EDIT- 已更改
date( \'Y-m-d\' )
到
date( \'Y-m-d\', current_time( \'timestamp\' ) )
获取相对于站点时区设置的日期。看见
current_time
在Codex中获取信息。