• Resolved curtisbillue

    (@curtisbillue)


    I’ve read several forums on this, tutorials and discussions on multiple loops and page numbers either not showing or recycling back to the starting posts, however I can’t seem to find the right combination to make it work. Hoping someone can give me some sort of insight.

    Here’s the site and two places in particular: http://s-usih.org and http://s-usih.org/blog
    Here’s the pastebin of the loops:

    http://pastebin.com/iEKm44Mq

    I have two custom WP_Query loops on a static home page that filter by category and showposts and wp_reset_postdata at the end of each. Those work fine. When I click on a title and go to each page and go previous and next, it works and will cycle through all of the posts.

    The third main loop is on my blogtemplate php file, and it is a query_posts filtering by category and posts_per_page, which works. However when I put any type of nav feature it either doesn’t show, or does show and the pages just restart back to the same posts no matter what page you try. Even this latest version I put a plugin WP Simple Pagination and although it shows the pages, it is stuck in that same loop again of showing the same posts regardless of what page number you click.

    What am I missing (besides great wisdom and experience)? I feel like I am close, just frustrated at my lack of understanding. Thanks CB

Viewing 4 replies - 1 through 4 (of 4 total)
  • Have you tried adding the ‘paged’ parameter? So instead of just

    //and 1 main loop on the blogtemplate where main blog is located:
    
    <?php query_posts('cat=1941&posts_per_page=3');

    maybe like this:

    // Normally the page number URL parameter should be 'paged' but I've also seen 'page' lately, so..
    $currentPage = get_query_var( 'page' ) ? (int) get_query_var( 'page' ) : null;
    
    if( $currentPage == null ) {
      $currentPage = get_query_var( 'paged' ) ? (int) get_query_var( 'paged' ) : 1;
    }
    
    $currentPage = abs( $currentPage );
    
    query_posts( 'cat=1941&posts_per_page=3&paged=' . $currentPage );
    Thread Starter curtisbillue

    (@curtisbillue)

    Haven’t tried that. Let me check it out and see what happens. Thanks Chris.

    Thread Starter curtisbillue

    (@curtisbillue)

    Awesome, that worked! Adding in the paged parameter and putting the plugin Simple Pagination worked. Thanks Chris!

    If you want to do it without a plugin, you can try this snippet – Multiple Post Type Loop & Pagination by Shortcode

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Multiple loops and Pagination issues’ is closed to new replies.