Php 当循环浏览页面而不是帖子时,如何生成分页?

Php 当循环浏览页面而不是帖子时,如何生成分页?,php,wordpress-theming,wordpress,Php,Wordpress Theming,Wordpress,本质上,我需要的是生成等效的,如果这是一个博客布局,导航下导航前一个链接,这是默认的2012年主题。。。我相信它使用了以下功能: next_posts_link() 我需要一个下一页链接()什么的。这是一个“一页”的布局。我不是负责人,我只是想知道如何实现这一点,我没有主意 如果没有一个函数可以将页面分组并作为单个页面返回-我需要创建一个,我不是php专家。。。比如: >>grab list of pages from database, >>group pages in

本质上,我需要的是生成等效的,如果这是一个博客布局,导航下导航前一个链接,这是默认的2012年主题。。。我相信它使用了以下功能: next_posts_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.
读一堆

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; ?>
}
$args=array(
“已分页”=>已分页,
“每页发布”=>5,/-1显示所有
“post_type”=>“page”,
“抑制_过滤器”=>true
);
$posts=新的WP_查询($args);
如果($posts->have_posts()){
而($posts->have_posts()):$posts->the_post(){
//对这里返回的邮件进行处理
}

}