Here is the code to get your posts pagination. Here you give the number of posts which you want to print in the every page. Chang something according your custom post type or other.
// WP_Query arguments
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array (
'post_type' => 'news', // Change according post type
'post_status' => 'publish',
'pagination' => true,
'posts_per_page' => '2', // change according you.
'paged' => $paged
);
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
// do something
}
echo '';
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
1 Comment(s)