所以我有一个名为“Events”的自定义帖子类型。在每个事件中,我都有一个名为“start_time_date”的自定义字段,它返回“08/01/12”之类的日期。我将如何排序这些帖子来返回帖子,以便帖子按照start_time_date按升序排序(start_time_dates接近当前日期首先显示)。如何按自定义日期排序WordPress查询?
这里是我当前的代码:
<? query_posts("cat=$currentID&showposts=100"); ?>
<? if (have_posts()) : ?>
<? while (have_posts()) : the_post(); if (time() < strtotime(get('end_time_date'))) :?>
<? $originalDate = get('start_time_date'); $newDate = date("M j, Y", strtotime($originalDate)); ?>
<div class="post">Some Post Data</div>
<? endif; endwhile; ?>
<? endif; ?>
是的。这只是由默认的WordPress发布日期排序。我想按自定义日期字段进行排序 – raeq 2012-07-31 19:31:46
我更新了我的答案,以包含指向文章的链接。 – Biotox 2012-07-31 19:48:09
谢谢。这工作 – raeq 2012-08-01 15:47:54