• 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:

    <?php
    		    $recentPosts = new WP_Query();
    		    $recentPosts->query('showposts=8orderby=date');
    		    while ($recentPosts->have_posts()) : $recentPosts->the_post();
    
    		?>

    and the following code to call second column of posts:

    <?php
    		    $recentPosts = new WP_Query();
    		    $recentPosts->query('showposts=8&offset=8');
    		    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.

    Lawrence

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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();
    $recentPosts->query('orderby=date&cat=20');
    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.