Support » Fixing WordPress » 2 column, 2 query loops, adding pagination

  • interlude22


    Hello all,

    I have some searching for a solution to my problem here, I have found a few articles and threads that are sniffing around the solution, I’m having trouble pulling it all together though.

    I want to create a pagination menu on the homepage that has 2 custom query loops. I’m using the following code to call the 1st column of posts:

    		    $recentPosts = new WP_Query();
    		    while ($recentPosts->have_posts()) : $recentPosts->the_post();

    and the following code to call second column of posts:

    		    $recentPosts = new WP_Query();
    		    while ($recentPosts->have_posts()) : $recentPosts->the_post();

    When I use wordpress’s own pagination and PagNavi plugin the query is just repeated so only the first 16 posts in the loop will be displayed regardless of using the pagination menu.

    What modifications do I need to make to this query so when a request is made for the 2nd ‘page’ of news stories WP knows to move onto the next 16 posts and not repeat the same most recent 16.

    The site where this code is running is live at : LOCWS International

    If I have omitted anything here, please let me know and I will hopefully be able to shed some light on it. Thanks for your time and help.


Viewing 2 replies - 1 through 2 (of 2 total)
  • dor


    Well, since i’ve not tried such things, i can not tell what exactly should be done.

    But i would try the following:
    – to read about “preserving original query” and preserve it;
    – to fetch all 16 items in one query and fill both columns with them…

    Yes, probably these two for the beginning.

    Sorry, these are only thoughts, i’ve not tried anything similar.

    This worked for me:

    $recentPosts = new WP_Query();
    if ($recentPosts->have_posts()) : ?>
    <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><b><?php the_title(); ?></b></a>
    <?php the_content('Read the rest of this entry &raquo;'); ?>
    <?php endwhile; ?>
    <?php else : ?>
    <h2 class="center">Not Questions Found.</h2>
    <?php endif; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘2 column, 2 query loops, adding pagination’ is closed to new replies.