WP_Query and paging problem
-
So I’ve got this code placed on both my index.php page and my single.php page.
The idea is to show the most recent four posts, excluding the current post being displayed. I’d also like the next_posts_link and previous_posts_link to display the appropriate pages of results.
The issue is that the code works perfectly on my index.php page, but on the single.php page, when you click on the next/prev page links it re-shows the same four posts.
Please, can someone help me find out why the code is being treated differently?
<?php global $paged; $this_post = $post->ID; $wp_query = new WP_Query(); $wp_query->query(array('post__not_in' => array($this_post), 'posts_per_page' => 4, 'paged' => $paged)); ?> <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <div style="width: 224px; float: left; margin-right: 10px;"> <a href="<?php the_permalink() ?>"><h4><?php the_title(); ?></h4></a><br /> <a href="<?php the_permalink() ?>"><?php the_post_thumbnail(array(224,224)); ?></a> </div> <?php endwhile; ?> <div style="clear: both;"></div> <?php next_posts_link('« Older Entries', $wp_query->max_num_pages) ?> <?php previous_posts_link('Newer Entries »') ?> <?php wp_reset_query(); ?>
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘WP_Query and paging problem’ is closed to new replies.