WordPress /page/2 not working

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!

Read More
    <?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(); ?>

Related posts

2 comments

  1. Don’t use query_posts, ever.

    The first 6 queries can be condensed to a single WP_Query:

    $args = array(
        'cat' => 3598,
        'posts_per_page' => 6
    );
    
    $featured = new WP_Query( $args );
    
    if( $featured->have_posts() ){
    
        $featured->the_post();
        ?>
        your markup for the first post
        <?php
    
        $featured->the_post();
        ?>
        your markup for the second post
        <?php
    
        $featured->the_post();
        // etc..
    
        wp_reset_postdata();
    }
    

    For the main query, use the pre_get_posts action with a function in your theme’s functions.php. This avoids wasting a query when you overwrite it in the template.

    function wpa_exclude_categories( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'category__not_in', array( 683, 3598 ) );
        }
    }
    add_action( 'pre_get_posts', 'wpa_exclude_categories' );
    

    You’ve now chopped 6 queries from every page load, and your pagination will magically work, do a little dance.

  2. <?php query_posts('cat=-683,-3598' . $paged); ?>
    

    This line should be

    <?php query_posts('cat=-683,-3598&paged=' . $paged); ?>
    

Comments are closed.