【发布时间】:2016-06-22 17:43:18
【问题描述】:
我正在开发一个活动网站,其中包含按两个自定义字段排序的所有活动日历
date_start - 活动日期。数据是这样存储的 20160622 今天 > 22/06/2016
time_start - 事件在这一天开始的时间。数据存储为德国使用。 上午 10 点 = 10:00 / 下午 3 点 = 15:00 / 晚上 8 点 = 20:00
仅按 date_start 对事件进行排序效果很好。
$query = new WP_Query( array(
'post_type' => 'veranstaltungen',
'post_status' => 'publish',
'cat' => '1,2,3,4,5',
'posts_per_page' => -1,
'meta_key' => 'date_start',
'orderby' => array( 'meta_value_num' => 'ASC'),
'order' => 'DESC'
));
现在我正在寻找一种解决方案,也可以使用 time_start 的自定义字段。 如果活动在下午 3 点 (15:00) 开始,则不应在晚上 8 点 (20:00) 活动之后显示。
在我的情况下,如何正确使用“meta_query”按日期和时间对自定义飞行进行排序?
【问题讨论】:
标签: wordpress sorting custom-fields date-sorting