Wordpress pagination on a query


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



Copy this code and paste it in your HTML
  1. <?php
  2. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  3. query_posts('posts_per_page=3&paged=' . $paged . '');
  4. ?>
  5.  
  6. <?php if (have_posts()) :
  7. $my_query = new WP_Query('category_name=testcat'.'&paged='.$paged 'posts_per_page=3');
  8. while ( $my_query->have_posts() ) : $my_query->the_post();
  9. ?>
  10.  
  11. <?php if (have_posts()) : ?>
  12. <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  13. query_posts("category_name=testcat&paged=$paged&posts_per_page=3"); ?>
  14. <?php while (have_posts()) : the_post(); ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.