Custom post type list with pagination in while loop


<?php

$loop = new WP_Query(array(‘post_type’ => ‘custom_post’,  ‘posts_per_page’ => 5,  ‘paged’ => get_query_var(‘paged’) ? get_query_var(‘paged’) : 1 ));

?>

<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

<?php the_title(); ?> <?php the_content(); ?>

<?php endwhile; ?>

<?php  $uniqnum = 999999999;

echo paginate_links( array( ‘base’ => str_replace( $uniqnum, ‘%#%’, get_pagenum_link( $uniqnum ) ),

‘format’ => ‘?paged=%#%’,

‘current’ => max( 1, get_query_var(‘paged’) ),

‘total’ => $loop->max_num_pages ) );

?>

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s