WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Blog Previous and Next links not working properly (3 posts)

  1. rosacreative
    Member
    Posted 3 years ago #

    I can't figure out why the Previous and Next links on my blog page will not link to the correct page. The same posts come up when I click on "Older Posts".

    Under the "Reading" Setting, I have it set to 5 posts per page.

    http://www.rosacreative.com/blog

    This is the code on index.php:

    <div class="posts">
                    <?php query_posts('cat=-13'); ?>
    					<?php if (have_posts()) : ?>
    						<?php while (have_posts()) : the_post(); ?>
    							<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
                                	<div class="date"><?php the_time('M') ?><br /><?php the_time('d') ?></div>
    								<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    								<small>posted in <span class="category"><?php the_category(' | ') ?></span></small>
                                    <div class="post-thumb"><a class="thumb" href="<?php the_permalink() ?>"><?php the_post_thumbnail('post'); ?></a></div>
    								<div class="entry"><?php the_content('…',TRUE,''); ?></div>
    
    								<div class="postmeta more">
    									<a class="standout" href="<?php the_permalink() ?>"><span>keep reading »</span></a> 
    									<?php comments_popup_link('leave a comment', '<span>1 comment</span>', '<span>% comments</span>', 'comments-link'); ?>
                                        <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    								</div>
    							</div>
    
    						<?php endwhile; ?>
    
    						<div class="nav">
    							<div class="alignleft prev"><?php next_posts_link('« Older Posts') ?></div>
    							<div class="alignright next"><?php previous_posts_link('Newer Posts »') ?></div>
    						</div>
    
    					<?php else : ?>
    						<h2 class="pagetitle">Not Found</h2>
    						<p class="center">Sorry, but you are looking for something that isn't here.</p>
    						<?php get_search_form(); ?>
    					<?php endif; ?>
    				</div><!-- end .posts -->
  2. simplistik
    Member
    Posted 3 years ago #

    http://codex.wordpress.org/Function_Reference/query_posts

    you need to add "$paged" when you used query_posts or else it won't paginate properly

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('cat=-13&paged=' . $paged);
    ?>
  3. rosacreative
    Member
    Posted 3 years ago #

    That did the trick. Thanks so much!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.