我正在使用PHP 7.3.5
and wordpress 5.2.x
.
我有以下自定义帖子类型:
register_post_type(\'Calendar-Events\', array(
\'supports\' => array(\'title\', \'editor\', \'thumbnail\', \'custom-fields\', \'excerpt\', \'comments\', \'revisions\'),
\'public\' => false,
\'show_ui\' => true,
\'exclude_from_search\' => true,
\'menu_position\' => 5,
\'labels\' => array(
\'name\' => \'Calendar Events\',
\'add_new_item\' => \'Add New Calendar Event\',
\'edit_item\' => \'Edit Calendar Event\',
\'all_items\' => \'All Calendar Events\',
\'singular_name\' => \'Calendar Event\',
),
\'menu_icon\' => \'dashicons-calendar-alt\',
));
我的帖子类型有一个称为
ce_timestamp
这是一个
Date Time Picker
并使用
ACF Version 5.8.7
.
我正在尝试查询ce_timestamp
字段晚于今天。
我尝试了以下方法:
$today = date(\'d/m/Y\');
try {
$args = array(
\'post_type\' => \'Calendar-Events\',
\'posts_per_page\' => -1,
\'post_status\' => \'publish\',
\'meta_query\' => array(
array(
\'key\' => \'ce_timestamp\',
\'value\' => $today,
\'type\' => \'DATE\',
\'compare\' => \'>=\'
)
),
\'meta_key\' => \'ce_timestamp\',
);
$upcomingEvents = new WP_Query($args);
if ( $upcomingEvents->have_posts() ) {
while ( $upcomingEvents->have_posts() ) {
$upcomingEvents->the_post();
// now $query->post is WP_Post Object, use:
// $query->post->ID, $query->post->post_title, etc.
}
}
wp_reset_postdata();
} catch (\\Exception $ex) {
error_log($ex);
}
然而,我没有得到任何回报。
有什么建议我做错了什么?
感谢您的回复!