Thursday, December 4, 2014

Wordpress Post Pagination

<?php

 $temp = $wp_query;
 $wp_query= null;
 $wp_query = new WP_Query();
$args = array(
 'category__in' => array( 3 ),
'posts_per_page' => 3,
  'paged' => $paged,
   'order' => 'DESC',
            );
            $wp_query->query($args);
            $max_page = $wp_query->max_num_pages;

            while ($wp_query->have_posts()): $wp_query->the_post();  ?>


Your Content


<?php      endwhile;

$big = 999999999; // need an unlikely integer

echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $max_page
) );

wp_reset_query();

?>

No comments:

Post a Comment