按日期排序的WordPress ACF字段不起作用

时间:2018-01-22 13:44:15

标签: php wordpress

我有两个WordPress参数数组,我正在向get_posts提交事件。

网站的前端标有Events | Previous Events

$today = date('Y-m-d'); // e.g. 2018-01-21

以下是我的论点:

$args = [
"post_type" => "events",
"post_status" => "publish",
"posts_per_page" => -1,
"meta_query" => [
    "key" => "date",
    "value" => $today,
    "compare" => ">=", // Greater than or equal to today's date (Y-M-D)
    "type" => "DATE 
],
"orderby" => "meta_value",
"order" => "ASC"
];

我之前发生的事件的查询是"meta_query" => "compare" => "<"

但是,我收到了每个标签上的所有活动。所有事件都没有发生,所以我希望当前将previous events作为空标签。

按如下方式循环播放

$events = get_posts($args);
foreach($events as $post) : setup_postdata($post);
// Mark up
endforeach; wp_reset_postdata();

0 个答案:

没有答案