[resolved] next page links on HP looping error (3 posts)

  1. markoburns
    Posted 5 years ago #

    Hi - In my categories all my next page/previous page links work fine, but on the homepage after clicking next page they just show the 1st page content over and over even though the url shows http://www.website.com/page/2/ etc.,

    I presume this is come kind of query error? Should I be using a separate template for categories and index with a separate query?

    here my index.php:

    <?php get_header(); ?>
    	<?php get_sidebar(); ?>
    	<div id="content" class="narrowcolumn" role="main">
    	<?php if (have_posts()) : ?>
       if (is_home()) {
    		<?php while (have_posts()) : the_post(); ?>
    			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    				<div class="entry">
    					<?php the_content('Read the rest &raquo;'); ?>
    		<?php endwhile; ?>
    		<div class="navigation prevnext">
    			<div class="alignright"><?php next_posts_link('Next Page &raquo;') ?></div>
    			<div class="alignleft"><?php previous_posts_link('&laquo; Previous Page') ?></div>
    	<?php else : ?>
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    		<?php get_search_form(); ?>
    	<?php endif; ?>
    <?php get_footer(); ?>
  2. esmi
    Forum Moderator
    Posted 5 years ago #

    Try changing query_posts("cat=-3"); to:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=-3&paged=" . $paged);
  3. markoburns
    Posted 5 years ago #

    Brilliant thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic