我需要比今天晚些时候获得带有类型event和自定义字段“date”的帖子,这个代码示例对我来说非常适合,我希望它能帮助处于类似情况的人。
$today = date("Y-m-d");
$today1 = date("Ymd", strtotime("$today"));
$custom_meta = array(
array(
\'key\' => \'data_de_inicio\',
\'value\'=>$today1,
\'compare\'=>\'>\',
\'type\'=>\'date\',
),
);
$query = new WP_Query(array(
\'post_type\'=>\'event\',
\'showposts\'=>\'3\',
\'orderby\'=>\'meta_value\',
\'meta_key\'=>\'data_de_inicio\',
\'order\'=>\'asc\',
\'meta_query\'=>$custom_meta,
)
);