Wordpress Custom post page with pagination
pagination, wordpress
Solution
Heres the way you can do it without pagination plugin :) using `WP_QUERY` instead of `query_posts`
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; // setup pagination
$the_query = new WP_Query( array(
'post_type' => 'clients',
'paged' => $paged,
'posts_per_page' => 5)
);
while ( $the_query->have_posts() ) : $the_query->the_post();
echo '<div>' . get_the_title() . '</div>';
the_content();
endwhile;
echo '<nav>';
echo '<div>'.get_next_posts_link('Older', $the_query->max_num_pages).'</div>'; //Older Link using max_num_pages
echo '<div>'.get_previous_posts_link('Newer', $the_query->max_num_pages).'</div>'; //Newer Link using max_num_pages
echo "</nav>";
wp_reset_postdata(); // Rest Data
Problem
I have custom post types called clients, need to display 5 clients per page with pagination. The page what i have is page-clients.php I have used the wp_pagenavi plugin. I get a perfect navigation list 1,2,3 etc etc but on clicking them takes me to page not found My Code ``` $args = array( 'posts_per_page' => 5, 'post_type' => 'clients', 'paged' => get_query_var('page') ); query_posts($args); <?php while ( have_posts() ) : the_post(); ?> ..... <?php endwhile; // end of the loop. ?> <?php wp_pagenavi(); ?> <?php wp_reset_query();?> ```