WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Paginating Posts

[Resolved] Paginating Posts

  • Need to show posts within a specific category and paginate. Pagination appears and is able to identify the correct amount of posts, but when moving from New to Old entries, the posts do not change. The URL changes correctly (…page/2/) but the same posts appear. Tried a variety of ways yet no solution seems to work.

    <?php
    /*
    Template Name: Page-Blog
    */
    
    get_header(); ?>
    
    	<h1><?php the_title(); ?></h1>
    
    	<?php get_sidebar(); ?>
    
    	<?php query_posts('cat=4&posts_per_page='.get_option('posts_per_page')); ?>
    
    		<?php if (have_posts()) : ?>
    
    			<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
    
    			<?php include (TEMPLATEPATH . '/inc/nav.php' ); ?>
    
    			<ul id="blog-posts">
    
    				<?php while (have_posts()) : the_post(); ?>
    
    					<li>
    
    						<div id="two-column">
    
    							<div <?php post_class() ?>>
    
    								<div class="entry">
    									<?php the_content(); ?>
    								</div>
    
    							</div>
    
    						</div>
    
    						<?php include (TEMPLATEPATH . '/sidebar-blog.php' ); ?>
    
    					</li>
    
    				<?php endwhile; ?>
    
    			</ul>
    
    			<?php include (TEMPLATEPATH . '/inc/nav.php' ); ?>
    
    	<?php else : ?>
    
    		<h2>Nothing found</h2>
    
    	<?php endif; ?>
    
    <?php get_footer(); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Add the ‘paged’ parameter to your query:

    <?php query_posts( 'cat=4&posts_per_page=' . get_option( 'posts_per_page' ) . '&paged=' . get_query_var( 'paged' ) ); ?>

    Thanks Big Bagel. Appreciate the help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Paginating Posts’ is closed to new replies.