WordPress Paginated WP_Query


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php $temp = $wp_query;
  2. $wp_query= null;
  3. $wp_query = new WP_Query();
  4. $wp_query?>query('showposts=5&category_name=thecategoryname'.'&paged='.$paged);
  5. ?>
  6. <?php while ($wp_query?>have_posts()) : $wp_query->the_post(); ?>
  7. <?php the_content(); ?>
  8. <?php endwhile; ?>
  9.  
  10. <div class="navigation">
  11. <div class="alignleft"><?php previous_posts_link('&laquo; Previous') ?></div>
  12. <div class="alignright"><?php next_posts_link('More &raquo;') ?></div>
  13. </div>
  14. <?php $wp_query = null; $wp_query = $temp;?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.