1<?php
2 // Full wp pagination example
3$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
4
5 $args = array(
6 'post_type' => 'blog',
7 'posts_per_page' => 10,
8 'paged' => $paged
9 );
10
11 // The Query
12 $the_query = new WP_Query( $args );
13
14 // The Loop
15 if ( $the_query->have_posts() ) {
16 while ( $the_query->have_posts() ) {
17 $the_query->the_post();
18 the_permalink();
19 the_title();
20 the_excerpt();
21 }
22 }
23 ?>
24
25 <div class="pagination">
26 <?php
27 echo paginate_links( array(
28 'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
29 'total' => $the_query->max_num_pages,
30 'current' => max( 1, get_query_var( 'paged' ) ),
31 'format' => '?paged=%#%',
32 'show_all' => false,
33 'type' => 'plain',
34 'end_size' => 2,
35 'mid_size' => 1,
36 'prev_next' => true,
37 'prev_text' => sprintf( '<i></i> %1$s', __( 'Newer Posts', 'text-domain' ) ),
38 'next_text' => sprintf( '%1$s <i></i>', __( 'Older Posts', 'text-domain' ) ),
39 'add_args' => false,
40 'add_fragment' => '',
41 ) );
42 ?>
43 </div>
1<?php
2 echo paginate_links( array(
3 'mid_size' => 3,
4 'prev_text' => __( '« Prev', 'textdomain' ),
5 'next_text' => __( 'Next »', 'textdomain' ),
6 ) );
7 ?>
1<?php
2$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
3
4$data= new WP_Query(array(
5 'post_type'=>'YOUR_POST_TYPE', // your post type name
6 'posts_per_page' => 3, // post per page
7 'paged' => $paged,
8));
9
10if($data->have_posts()) :
11 while($data->have_posts()) : $data->the_post();
12 // Your code
13 endwhile;
14
15 $total_pages = $data->max_num_pages;
16
17 if ($total_pages > 1){
18
19 $current_page = max(1, get_query_var('paged'));
20
21 echo paginate_links(array(
22 'base' => get_pagenum_link(1) . '%_%',
23 'format' => '/page/%#%',
24 'current' => $current_page,
25 'total' => $total_pages,
26 'prev_text' => __('« prev'),
27 'next_text' => __('next »'),
28 ));
29 }
30 ?>
31<?php else :?>
32<h3><?php _e('404 Error: Not Found', ''); ?></h3>
33<?php endif; ?>
34<?php wp_reset_postdata();?>
35