Pagination loading same posts, using multiple loops
-
This is my first WP site, so I assume I’m doing something obvious wrong. But I’ve been stuck here for days now and already went through the codex many times, as well as searched many threads. All help greatly appreciated.
The Blog page is not the homepage. It has a single Featured post at the top. Below that is another loop for the rest of the recent posts. The pagination is below this, but when I click to go to older posts, the URL will change to Page 2, but it loads all the exact same posts.
<div id="featured" class="clearfix"> <?php $query = new WP_Query( 'cat=4' ); ?> <?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?> <div class="thumbnail"> <?php the_post_thumbnail('feat-thumb', 400, 400, true); ?> </div> <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h2><a>"><?php the_title(); ?></a></h2> <?php include (TEMPLATEPATH . '/inc/meta.php' ); ?> <div class="entry"> <?php the_excerpt(); ?> </div> <div class="postmetadata"> <?php the_tags('Tags: ', ', ', ''); ?> Posted in <?php the_category(', ') ?> | <?php comments_popup_link('No Comments ?', '1 Comment ?', '% Comments ?'); ?> </div> <?php endwhile; ?> <?php else : ?> <h2>Not Found</h2> <?php endif; ?> </div> </div><!-- #featured close --> <div id="feed"> <?php $query2 = new WP_Query('posts_per_page=2'); ?> <?php if ( $query2->have_posts() ) : while ( $query2->have_posts() ) : $query2->the_post(); ?> <?php if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } elseif ( get_query_var('page') ) { $paged = get_query_var('page'); } else { $paged = 1; } query_posts('posts_per_page=2&paged=' . $paged); ?> <div id="feedthumb"> <?php the_post_thumbnail('blog-thumb', 400, 400, true); ?> </div> <div id="excerpt"> <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h2><a>"><?php the_title(); ?></a></h2> <?php include (TEMPLATEPATH . '/inc/meta.php' ); ?> <div class="entry"> <?php the_excerpt(); ?> </div> <div class="postmetadata"> <?php the_tags('Tags: ', ', ', ''); ?> Posted in <?php the_category(', ') ?> | <?php comments_popup_link('No Comments ?', '1 Comment ?', '% Comments ?'); ?> </div> </div><!-- #excerpt close --> </div> <?php endwhile; ?> <?php include (TEMPLATEPATH . '/inc/nav.php' ); ?> <?php else : ?> <h2>Not Found</h2> <?php endif; ?>
I’ve tried so many things at this point, I don’t quite remember how the code even got to this particular mutation. I feel like I’m close though. Thank you.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Pagination loading same posts, using multiple loops’ is closed to new replies.