如何消除“日期”值过期的自定义帖子?

时间:2012-03-16 作者:marctain

我有此代码调用自定义post事件列表。它按正确的顺序调用它们,但当事件传递时,它仍然显示事件。你知道代码有什么问题吗?

  $args2 = array(
    "post_type" => "gig",
    "meta_key" => "_gigswhen", // Change to the meta key you want to sort by
            "meta_query" => array(
            array(
             "meta_key" => "_gigswhen",
             "value" => date(),
                "compare" => ">=",
           ),
     ),
    "orderby" => "meta_value_num", // This stays as \'meta_value\' or \'meta_value_num\' (str sorting or numeric sorting)
    "order" => "ASC"
    );
“\\u gigswhen”中的日期存储为strotime(unix时间码)

1 个回复
最合适的回答,由SO网友:Boone Gorges 整理而成

您不能使用date() 没有参数。看见http://php.net/manual/en/function.date.php.

为您的meta_query 参数:

\'meta_query\' => array(
    array(
        \'key\' => \'_gigswhen\',
        \'value\' => time()
        \'compare\' => \'<\'
    )
)

结束

相关推荐