wordpress pagination with query_posts

wordpress pagination with query posts

wordpress pagination with query posts, Mostly people use query_posts function for fetching posts. But most of all people face issue with pagination.

wordpress pagination with query posts

Just use following code for pagination. It is simple and easy.

<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts( 'post_type=documents&paged='.$paged );
query_posts( 'post_type=post&paged='.$paged );
if (have_posts()) : while (have_posts()) : the_post(); ?>

<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
<?php the_excerpt();  ?>

 <?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(); ?>

wordpress pagination with query_posts
wordpress pagination with query_posts

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

One thought on “wordpress pagination with query posts”

Leave a Reply

Your email address will not be published.