我不明白你的问题。确切地
是否要下一页、上一页和后一页?
或
想查看下一篇和上一篇文章的标题或其他内容吗?
实际上,您将一个不正确的值放置到偏移位置。你必须这样做。
// Initialize where to start the post from, 0 is most recent post
$init_count = 0;
// Get the current page integer
$page = get_query_var( \'paged\' ) ? get_query_var( \'paged\' ) : 1;
// And the simple formula for offset is this
$offset = ( $page - 1 ) * $init_count;
//Now you should use your query like this:
<?php $upcoming_events_args = array(
\'post_type\' => \'event\',
\'meta_key\' => \'start_date\', // name of custom field
\'orderby\' => \'meta_value_num\',
\'order\' => \'ASC\',
\'posts_per_page\' => \'3\',
\'number\' => $init_count,
\'page\' => $page,
\'offset\' => $offset,
\'meta_query\' => array(
array(
\'key\' => \'start_date\',
\'value\' => $date_of_page,
\'compare\' => \'>=\',
\'type\' => \'DATE\'
))
);
通过将此代码放在循环结束后,将显示您的下一篇和上一篇文章。
<ul class="pagination">
<li id="previous-posts">
<?php previous_posts_link( \'<< Previous Posts\', $custom_query->max_num_pages ); ?>
</li>
<li id="next-posts">
<?php next_posts_link( \'Next Posts >>\', $custom_query->max_num_pages ); ?>
</li>
</ul>