Skip to content

Instantly share code, notes, and snippets.

@korymath
Created November 20, 2013 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korymath/7571835 to your computer and use it in GitHub Desktop.
Save korymath/7571835 to your computer and use it in GitHub Desktop.
Pagination of Custom Post Type in WordPress
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'paged' => $paged,
'post_type' => 'review-single',
'category_name' => types_render_field("category-slug-to-pull", array()),
'posts_per_page' => '10'
));
$the_query = new WP_Query( $args );
if( have_posts() ) :
while( have_posts() ) : the_post();
echo ('<li>'.the_title().'</li>');
endwhile;
endif;
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $the_query->max_num_pages
));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment