Created
November 20, 2013 21:58
-
-
Save korymath/7571835 to your computer and use it in GitHub Desktop.
Pagination of Custom Post Type in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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