我想比较a中的两个时间戳meta_query
而不是comparing two dates 在“Y-m-d”格式中,它们各自单独存储在自定义字段中,但没有成功。第一个时间戳是事件开始日期/时间,第二个是本地日期/时间,也作为时间戳。当我在代码中使用它们时,帖子会以不可理解的顺序显示。这里怎么了?“Y-m-d”格式的日期比较工作正常。
function add_custom_post_type_to_query( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( \'post_type\', array( \'facebook_events\', \'event\' ) );
$query->set( \'meta_query\', array(
\'relation\' => \'OR\',
array(
\'key\' => \'start_ts\', //this is from facebook_events post type
\'value\' => current_time( \'timestamp\' ),
\'compare\' => \'>=\',
\'type\' => \'DATE\',
),
array(
\'key\' => \'_start_ts\', //this is from event post type
\'value\' => current_time( \'timestamp\' ),
\'compare\' => \'>=\',
\'type\' => \'DATE\',
)
) );
$query->set( \'orderby\', \'meta_value\' );
$query->set( \'order\', \'ASC\' );
}
}
add_action( \'pre_get_posts\', \'add_custom_post_type_to_query\' );