0
我使用wordpress的高级自定义字段插件来创建一组自定义帖子类型,其中设置了一个日期。Wordpress输出链接到自定义查询的上一篇和下一篇文章
我想根据存储在自定义字段中的日期显示上一篇文章和下一篇文章。链接需要链接到日后设置日期的帖子(所以不要显示日期已过的帖子的链接)/
我可以获得未来所有帖子的列表,并使用下面的代码进行输出:
<?php
$rightnow = current_time('Ymd');
$args = array(
'post_type' => 'Courses',
'posts_per_page' => '25',
'meta_query' => array(
array(
'key' => 'date_of_the_course_single_day',
'compare' => '>=',
'value' => $rightnow,
)
),
'meta_key' => 'date_of_the_course_single_day',
'orderby' => 'meta_value',
'order' => 'ASC',
'post_status' => 'publish'
);
$posts = get_posts($args);
foreach ($posts as $post) {
?>
Output details of post here....
<?php
}
?>
我想我可以做的,是得到当前职位的数组位置中,以再拿到帖子一前一后...的细节,但我没有得到一个线索如何做这个。
我已经试验过wordpress的next_post_link和previous_post_link函数,但是这些似乎是基于WordPress的帖子被添加的时候,而不是基于我的自定义日期字段。
我该怎么处理这个完全错误的方法?任何提示或指针将不胜感激!