基本上我需要的是生成等效的,如果这是一个博客布局,导航下面的nav-previous链接是2012年主题中的默认链接...我相信使用该功能: 的 next_posts_link();
我需要一个 next_PAGES_link(); 等等。这是一个“单页”布局。我不负责我只需要弄清楚如何实现这一点,我就没有想法了。
如果没有将页面组合在一起并将它们作为单个页面返回的功能 - 我需要创建一个并且我不是php专家...类似于:
>>grab list of pages from database,
>>group pages into array pageGroup- each group of pages in pageGroup contains (x) number of pages
>>return each pageGroup item as a WordPress page.
>>generate link to new the next pageGroup WordPress page at the bottom of every pageGroup page.
答案 0 :(得分:0)
在https://codex.wordpress.org/Pagination
读一堆Themble的Bones主题为他们自己的分页功能提供了一个完整的自定义代码库。它很棒,易于使用。我也会在Bones主题中研究它 - > library-bones.php。这是我从编码中得到的一种快速操作,它是未经测试但在逻辑上是正确的:
$args = array(
'paged' => paged,
'posts_per_page' => 5, //-1 shows all
'post_type' => 'page',
'suppress_filters' => true
);
$posts = new WP_Query( $args );
if ( $posts -> have_posts()) {
<!-- Add the pagination functions here. -->
while ( $posts -> have_posts() ) : $posts->the_post(); {
//do stuff with the posts returned here
}
<?php endwhile; ?>
<!-- End of the main loop -->
<!-- Add the pagination functions here. -->
<div class="nav-previous alignleft"><?php next_posts_link( 'Older posts' ); ?></div>
<div class="nav-next alignright"><?php previous_posts_link( 'Newer posts' ); ?></div>
<?php else : ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
}