WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Index pagination shows every page as page 1 (7 posts)

  1. Stargirl2
    Member
    Posted 3 years ago #

    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 http://techettes.com.

  2. vtxyzzy
    Member
    Posted 3 years ago #

    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.

  3. jjoves
    Member
    Posted 3 years ago #

    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

  4. Stargirl2
    Member
    Posted 3 years ago #

    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(); ?>
  5. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    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(); ?>
  6. Stargirl2
    Member
    Posted 3 years ago #

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

  7. dimofamo
    Member
    Posted 3 years ago #

    Alchymyth you just became my personal god!

Topic Closed

This topic has been closed to new replies.

About this Topic