By default, in WordPress, a page name and custom post type can’t have the same name. Well, using the snippet below, you will be able to display custom posts with pagination.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | <h1><?php the_title(); ?></h1> <?php the_content(); ?><br /><br /> <?php $i = 0; ?> <?php $loop = new WP_Query( array( 'post_type' => 'testimonial', 'orderby'=> date, 'paged' => get_query_var( 'paged' ), 'posts_per_page' => 5 ) ); ?> <?php if ( function_exists( 'wp_pagenavi' ) ) { wp_pagenavi( array( 'query' => $loop ) ); wp_reset_postdata(); } ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class="testimonial-block"> <?php $authorpic = get('testimonial_info_image'); $authortitle = get('testimonial_info_title_company'); ?> <?php if ($authorpic != NULL) { ?><img src="<?php echo $authorpic; ?>" alt="person" class="testimonial-pic" /><?php } ?> <?php the_content(); ?> <strong><?php the_title(); ?><br /> <?php if ($authortitle != NULL) { ?><br /><?php echo $authortitle; ?><?php } ?></strong> <small><?php echo date("m\/d\/y"); ?></small> </div> <?php $i++; endwhile; ?> <div class="clear"><br /><br /></div> <?php if ( function_exists( 'wp_pagenavi' ) ) { wp_pagenavi( array( 'query' => $loop ) ); wp_reset_postdata(); } ?> |
Snippet Source/Credit: WordPress.org