+ Reply to Thread
Results 1 to 3 of 3

Thread: Pagination With Multiple Loops Not Cycling Through Posts

  1. #1
    Jarret's Avatar
    Jarret is offline Hello World
    Join Date
    Feb 2009
    Location
    California
    Posts
    21

    Default Pagination With Multiple Loops Not Cycling Through Posts

    Ok, so another issue that I have run into is the fact that I have 2 loops running on the main page of the site but when trying to view older/newer posts I keep getting the same posts showing up so something is wrong with the pagination.

    I'm using just a standard query_posts to pull the first 2 posts that I am displaying then I used another query_posts to pull the rest of the 7 posts that are displayed.

    I've tried using posts_nav_link as well as the regular next/previous_posts_link but I'm still having issues with the posts not actually cycling through like they should. I'm obviously missing something here, anybody have any insight? I can post code if need be so let me know.

  2. #2
    DD32 is offline Hello World
    Join Date
    Jul 2009
    Posts
    39

    Default

    Have a look at this:
    http://www.mikechick.net/2008/07/fix...n-query-posts/

    Make sure you run get_query_var() before ANY query_posts on the page though.

    heres a sniplet of code from that page:
    Code:
    <?php
    $limit = get_option('posts_per_page');
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('showposts=' . $limit . '&paged=' . $paged .'&cat=-166,-167,-168');
    $wp_query->is_archive = true; $wp_query->is_home = false;
    ?>
      <?php if (have_posts()) : ?>
    
    ..I'm not sure what the go is with people wraping booleans in () though, I also like the array style calling..

    Code:
    $page = get_query_var('paged') ? get_query_var('paged') : 1;
    query_posts(
        array( 'showposts' => get_option('posts_per_page'),
                  'paged' => $page,
                  'cat' => array(-166, -167, -168)
        ) );
    

  3. #3
    Jarret's Avatar
    Jarret is offline Hello World
    Join Date
    Feb 2009
    Location
    California
    Posts
    21

    Default

    Thanks for the info DD32! I'll take a look into it and let you know what happens :)

    EDIT -- It worked perfectly DD32, thanks once again for the quick reply
    Last edited by Jarret; 07-19-2009 at 12:14 PM. Reason: Updating post

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts