我创建了一个名为“事件”的自定义帖子类型。在索引页面上,我想修改循环以列出所有帖子(标准和事件)。但是,我希望按发布日期对标准帖子进行排序,并希望按包含事件日期的自定义字段对事件进行排序。
示例:
Standard Post (Posted on 12th May 2014)
Standard Post (Posted on 11th May 2014)
Event Post (10th May 2014)
Standard Post (Posted on 9th May 2014)
Event Post (8th May 2014)
Event Post (7th May 2014)
Standard Post (Posted on 6th May 2014)
我在索引上为query\\u post添加了这些参数。php
<?php
query_posts( array(
\'post_type\' => array( \'events\', \'post\'),
\'meta_key\' => \'date_of_event\',
\'orderby\' => \'meta_value\',
\'order\' => \'asc\',
\'meta_query\' => array(
\'key\' => \'date_of_event\',
\'value\' => date("Ymd"),
\'compare\' => \'>=\',
\'type\' => \'DATE\'
)
)
);
?>
目前我只返回事件