When clicking the next_posts_link it just shows the same posts as on page 1. It appears to work fine on the category pages and it is only affecting the homepage (home.php)
Thanks!
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
<?php query_posts('cat=-683,-3598' . $paged); ?>
FULL CODE
<?php get_header(); ?>
<div id="featured">
<div id="featured_left">
<div id="block1">
<?php query_posts('cat=3598&showposts=1'); ?>
<?php while(have_posts()) : the_post(); ?>
<?php the_post_thumbnail('fbox12'); ?>
<?php endwhile; ?>
</div>
<div id="block2">
<?php query_posts('cat=3598&showposts=1&offset=1'); ?>
<?php while(have_posts()) : the_post(); ?>
<?php the_post_thumbnail('fbox12'); ?>
<?php endwhile; ?>
</div>
</div>
<div id="featured_middle">
<div id="block3">
<?php query_posts('cat=3598&showposts=1&offset=2'); ?>
<?php while(have_posts()) : the_post(); ?>
<?php the_post_thumbnail('fbox3'); ?>
<?php endwhile; ?>
</div>
<div id="block6">
<?php query_posts('cat=3598&showposts=1&offset=3'); ?>
<?php while(have_posts()) : the_post(); ?>
<?php the_post_thumbnail('fbox67'); ?>
<?php endwhile; ?>
</div>
<div id="block7">
<?php query_posts('cat=3598&showposts=1&offset=4'); ?>
<?php while(have_posts()) : the_post(); ?>
<?php the_post_thumbnail('fbox67'); ?>
<?php endwhile; ?>
</div>
</div>
<div id="featured_right">
<div id="block4">
<?php query_posts('cat=3598&showposts=1&offset=5'); ?>
<?php while(have_posts()) : the_post(); ?>
<?php the_post_thumbnail('fbox45'); ?>
<?php endwhile; ?>
</div>
</div>
</div>
<div id="left">
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
<?php query_posts('cat=-683,-3598&paged=' . $paged); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="post_item">
<?php
if ( has_post_thumbnail() ) {
?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_post_thumbnail('homepage-thumb'); ?></a>
<?php }
else { ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/no_thumb.png"/></a>
<?php }
?>
<h2><?php the_category(', '); ?> | <?php the_time('F j, Y'); ?></h2>
<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_excerpt(); ?></a>
</div>
<?php endwhile; ?>
<?php endif; ?>
<div class="pagenav">
<div class="pagenavright"><?php next_posts_link('Next Entries','') ?></div>
</div> <!-- end navigation -->
</div>
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>
Don’t use
query_posts
, ever.The first 6 queries can be condensed to a single
WP_Query
:For the main query, use the
pre_get_posts
action with a function in your theme’sfunctions.php
. This avoids wasting a query when you overwrite it in the template.You’ve now chopped 6 queries from every page load, and your pagination will magically work, do a little dance.
This line should be