solved: pagination for Custom post type not working

solved wordpress custom post type pagination not working

From wordpress 3.0 version, wordpress started the custom post type functionality. There are API provided by wordpress for adding the pagination for custom post type. Some WP developers asked me about pagination of custom post type. That is very easy to add the pagination. Here in this article I given the code snippet for showing the pagination in custom post type.

solved wordpress custom post type pagination not working

For showing the custom post type we always use the query_post method.

Just use the following code in your template or theme file.

<?php get_header(); ?>

            <?php  query_posts( 'post_type=custom-post-type&paged='.$paged );
                                    if (have_posts()) : while (have_posts()) : the_post(); ?>

//loop here

              			<?php endwhile; ?>
				  <div id="nav-below" class="navigation">
					<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyten' ) ); ?></div>
					<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?></div>
				  </div><!-- #nav-below -->
				  <?php endif; wp_reset_query(); ?>

<?php get_footer(); ?>
solved wordpress custom post type pagination not working
solved wordpress custom post type pagination not working

Have fun!

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.