Solution for : How to include pagination in a Wordpress Custom Post Type Query
If we have to get the list for custom post type "project". Below is simple code to achieve our goal.
$the_query = new WP_Query(
array('posts_per_page'=>20,
'post_type'=>'project',
'paged' => get_query_var('paged') ? get_query_var('paged') : 1)
);
while ($the_query -> have_posts()) : $the_query -> the_post();
echo '';
echo '';
echo get_the_title();
echo '';
echo '';
endwhile;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $the_query->max_num_pages
) );
wp_reset_postdata();
No comments:
Post a Comment