WordPress将分页添加到自定义帖子类型

In WordPress i'm currently using the below code to display both the content of the testimonials page and the posts from the custom post type testimonials.

I'm trying to add pagination but to no avail, no errors appear they just don't display. I'm guessing this probably has something to do with the fact i'm using two loops and having to reset, but i'm not sure?

Any more infomation required please ask.

<?php /* Template Name: Testimonials */ get_header(); ?>

<div id="main">

    <div class="fullwidth">

        <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

        <h1><?php the_field('h1_title'); ?></h1>

        <div class="width">

            <ul class="menu slider">

                <?php if(wp_list_pages('child_of='.$post->ID.'&echo=0&exclude=2')) { $list_of_pages = wp_list_pages('echo=0&title_li=&depth=1&child_of='.$post->ID.'&exclude=2'); $list_pages = explode('<li class="',$list_of_pages); $len = count($list_pages); for ($i = 0; $i <= $len-2; $i++) : echo $list_pages[$i] . '<li  class="list-item-' . ($i+1) . ' '; endfor; echo $list_pages[$i]; }

                elseif(get_the_title($post->post_parent) != the_title(' ' , ' ',false)) { $list_of_pages = wp_list_pages('echo=0&title_li=&depth=1&child_of='.$post->post_parent.'&title_li=&exclude=2'); $list_pages = explode('<li class="',$list_of_pages); $len = count($list_pages); for ($i = 0; $i <= $len-2; $i++) : echo $list_pages[$i] . '<li  class="list-item-' . ($i+1) . ' '; endfor; echo $list_pages[$i]; } ?>

            </ul>

        </div>

        <h2><?php the_field('h2_title'); ?></h2>

        <?php the_content(); ?>

        <?php endwhile; wp_reset_postdata(); ?>

        <div class="posts">

            <?php $query = new WP_Query( array ( 'post_type' => 'testimonial', 'order' => 'DESC', 'posts_per_page' => 9, 'orderby'=> menu_order ) ); while ( $query->have_posts() ) : $query->the_post(); ?>

            <div class="blog-post">

                <div class="content">

                    <h3><?php the_title();?></h3>

                    <h4><?php the_field('visit_date'); ?></h4>

                    <?php the_content(); ?>

                </div>

                <div class="clear"></div>
            </div>

            <?php endwhile; ?>

            <div class="navigation">

                <div class="alignleft"><?php previous_posts_link('&laquo; Previous') ?></div>

                <div class="alignright"><?php next_posts_link('More &raquo;') ?></div>

            </div>

        </div>

    </div>

    <?php get_footer(); ?>

I feel you are not getting and passing the page#, try to change/replace your code like this

$query = new WP_Query( array ( 'post_type' => 'testimonial', 'order' => 'DESC', 'posts_per_page' => 9, 'orderby'=> menu_order ) ); while ( $query->have_posts() ) : $query->the_post();

to

$page = (get_query_var('paged')) ? get_query_var('paged') : 1;

$query = new WP_Query( array ( 'post_type' => 'testimonial', 'order' => 'DESC', 'posts_per_page' => 9, 'orderby'=> 'menu_order','paged' => $page ) ); 
while ( $query->have_posts() ) : $query->the_post();