• Resolved stargirl2

    (@stargirl2)


    I am having an issue with pagination on my index page – I’ve done quite a bit of modification so I’ve probably messed something up and can’t figure out what. Now, whenever I click ‘next’ I am taken to the next page URL (/page/2/) but it shows the content from my index page. My categories are working fine, it’s just the homepage that’s an issue. Does anyone have any experience with this?

    I haven’t touched this section, but I assume it has something to do with this bit of code?

    <div class="navigation">
    
    		<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } 
    
    			else { ?>
    
    			<div class="right"><?php next_posts_link('Next Page &raquo;') ?></div>
    
    			<div class="left"><?php previous_posts_link('&laquo; Previous Page') ?></div>
    
    			<?php } ?>
    
    	</div>

    Any help would be appreciated. If relevant, the site is at https://techettes.com.

Viewing 6 replies - 1 through 6 (of 6 total)
  • I suspect that the problem is in the parameters to query_posts. You may be missing the ‘paged’ parameter. Since I can’t see your code, this may not be quite right, but I hope it will help:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("paged=$paged");

    Of course, you need to keep any other parameters you already have.

    Were you able to get this fix? I am having the same issue. sidebar(left) calls the query and single page(right) displays selecttion. however everytime I go to other post on the other pages the sidebar will go back to page1 even though the selected post is on page 2

    Thread Starter stargirl2

    (@stargirl2)

    Hmm, I thought that might be another place with an error by I think my code is correct. I’ve included a longer snippet of code below – including the paged parameter – if you see anything I’ve missed, that would be very helpful.

    I’m a bit concerned that, while modifying the page to bits, I removed some </div> somewhere so they’re not matching up – could that be making a difference?

    <div id="front-list">	
    
    	<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
    
    query_posts("cat=-27,-28&paged=$paged&posts_per_page=5"); ?>
    
    	<?php while (have_posts()) : the_post(); ?>		
    
    	<div class="clearfloat">
    
    	<h3 class=cat_title><?php the_category(', '); ?> &raquo</h3>
    
    	<div class="title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); 
    
    ?></a></div>
    
    	<div class="meta">[<?php the_time('j M Y') ?> | <?php comments_popup_link('No Comment', 'One 
    
    Comment', '% Comments');?>]</div>	
    
    	<div class="spoiler">
    
    	<?php	$values = get_post_custom_values("Image");
    
    	if (isset($values[0])) { ?>
    
          <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); 
    
    ?>">
    
    	<img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
    
    $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=150&h=150&zc=1&q=100"
    
    alt="<?php the_title(); ?>" class="left" width="150px" height="150px"  /></a>
    
          <?php } ?>
    
    	<?php the_excerpt(); ?>
    
    	</div>
    
    	</div>
    
          <?php endwhile; ?>
    
    	<div class="navigation">
    
    		<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } 
    
    			else { ?>
    
    			<div class="right"><?php next_posts_link('Next Page &raquo;') ?></div>
    
    			<div class="left"><?php previous_posts_link('&laquo; Previous Page') ?></div>
    
    			<?php } ?>
    
    	</div>
    
    	</div>
    
    	</div>	
    
    <?php get_footer(); ?>

    is there another query_posts() before tho code that you posted?

    is so, try and add a ‘wp_reset_query();’ in your posted code:

    <div id="front-list">
    
      <?php wp_reset_query(); ?>
    	<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
    
    query_posts("cat=-27,-28&paged=$paged&posts_per_page=5"); ?>
    
    	<?php while (have_posts()) : the_post(); ?>
    Thread Starter stargirl2

    (@stargirl2)

    AH brilliant! That’s solved the problem, thanks so much alchymyth!

    Alchymyth you just became my personal god!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Index pagination shows every page as page 1’ is closed to new replies.