Support » Fixing WordPress » multiple custom loops and pagination

  • I have to create a custom WordPress category.php page. I need a custom loop at the top pulling in the latest two posts in the category (these are styled differently). I then need a second custom loop pulling a second list of 10 latest posts in that category. the pagination then needs to work correctly.

    I have gone through so many posts regarding the pagination issue with query_posts() but can’t seem to get anywhere, please help!!

    here is what I am currently using:

    <?php query_posts('posts_per_page=2'); if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
    <!--first loop stuff-->
    <?php endwhile; endif; ?>
    <?php query_posts('offset=2'); if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
    <!--second loop stuff-->
    <?php endwhile; ?>
    	<?php include (TEMPLATEPATH . '/inc/nav.php' ); ?>
    	<?php else : ?>
    		<h2>Not Found</h2>
    	<?php endif; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Maybe you can try the following:

    $temp = $wp_query;
      $wp_query= null;
      $wp_query = new WP_Query('offset=2&paged=' . $paged);

    And then for the query:

    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>

    Hi Thanks for your suggestion, I used this for the query and it worked but I finally figured out that it was actually the fact that I was using “offset” in the query that was messing up the pagination.

    So pagination and wp_query “offset” gives issues. I eventually found a fix for this here:

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘multiple custom loops and pagination’ is closed to new replies.