<?php
/* Template Name: Demo - CPT with pagination
* Template will display listing of 'custom post type' along with pagination underneath (numerical style)
*/
?>
<?php get_header() ?>
<?php
$currentPage = get_query_var( 'paged' ); // Get var from query
$args = array(
'post_type' => 'product' // Custom post type
,'posts_per_page' => 2 // Max no of post to be displayed
,'paged' => $currentPage // get the current page no
);
$cptArr = new WP_Query($args);
if($cptArr->have_posts()) : // If post find in array
echo '<ul>';
while($cptArr->have_posts()) : // loop till last post procsessed
$cptArr->the_post();
echo '<li>';
the_title();
echo '</li>';
endwhile;
echo paginate_links( array('total' => $cptArr->max_num_pages) );
echo '</ul>';
endif;
?>
<?php get_footer() ?>