WordPress.org

Ready to get started?Download WordPress

Forums

"Next Posts" link not working (10 posts)

  1. Dayr12
    Member
    Posted 1 year ago #

    I cannot seem to get my "next posts" and "previous posts" links to work. At the bottom of my index.php I want visitors to navigate to "older posts" and "new posts". Pretty simple right?

    Well I followed the advice in the Codex. But no luck. Instead, when you click on the "older posts" link, the home page reloads with the newest three posts, not the three after those.

    Any help would be really appreciated!! I know I'm missing something...

    Here's what my loop is looking like:

    <?php
    if ( is_home() ) {
    	query_posts( 'cat=-3' );
    }
    ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    	<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    
    		<div class="date "><span class="floatleftdate"><?php the_time('M j') ?><br /><?php the_time('Y') ?></span></div>
    
    	    <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
    		<div class="date-inline meta"><?php the_time('F j, Y') ?></div>
    
    		<div class="entry">
    			<?php the_content('<div class="readmore">Read More »</div>'); ?>
    		</div>
    
    		<div class="clear">
    		</div>
    
    	</div>
    
    <?php endwhile; ?>
    
    <div class="navigation">
    	<div class="next-posts"><p><?php next_posts_link('Older Posts »') ?></p></div>
    	<div class="prev-posts "><?php previous_posts_link('« Newer Posts') ?></div>
    </div>
    
    <?php else : ?>
    
    	<h2>Not Found</h2>
    
    <?php endif; ?>
  2. egado
    Member
    Posted 1 year ago #

    Can you please post a link?

  3. Dayr12
    Member
    Posted 1 year ago #

    oops! Here it is: http://ipolitech.com/

  4. egado
    Member
    Posted 1 year ago #

    Can you try to move

    <div class="navigation">
    	<div class="next-posts"><p><?php next_posts_link('Older Posts »') ?></p></div>
    	<div class="prev-posts "><?php previous_posts_link('« Newer Posts') ?></div>
    </div>

    after this <?php endif; ?>

    just for make a test...

  5. egado
    Member
    Posted 1 year ago #

    And try this change pls, without doing what i'm posted before...

    find

    query_posts( 'cat=-3' );

    replace with

    query_posts( 'cat=-3&posts_per_page=3' );

    Let me know :)

  6. Dayr12
    Member
    Posted 1 year ago #

    Just moved it down there and the same problem exists. Still reloading the first three posts instead of moving on. Any other suggestions? Thanks for your help, btw!

  7. egado
    Member
    Posted 1 year ago #

    see above ;)

  8. Dayr12
    Member
    Posted 1 year ago #

    Still the same issue... Would it help to place the loop in it's own php file and call that in the index? Someone mentioned that might help, but I don't see why.

  9. egado
    Member
    Posted 1 year ago #

  10. Dayr12
    Member
    Posted 1 year ago #

    Howdy! I checked out those links... it looks like if it's a query problem caused by excluding a category at the outset of my loop. I could have changed around the loop it looks like, but I don't know PHP well enough to start hacking at that a ton.

    Long story short, I downloaded a plugin to take care of excluding my category, and got rid of the script that was screwing up my pagination. Seems like a WP bug to me!

    Anyway, thanks a ton for your help egado! All works now!

    Robbie

Topic Closed

This topic has been closed to new replies.

About this Topic