WordPress.org

Ready to get started?Download WordPress

Forums

Pagination on custom page template (2 posts)

  1. bobbyadamson
    Member
    Posted 4 years ago #

    I'm using a static homepage with custom page templates on each page for a portfolio website. I'm working on the blog page, and everything works except for pagination. Someone else had this same problem but their previous and next buttons were leading to 404s. Mine work, but they don't change the posts. Meaning, it will recognize that it has gone to page 2, but the same posts that were on page 1 are still displayed.

    I have multiple loops running, and I thought that might be the problem, but when the other loop was removed, it was the same.

    Here's my code

    <?php
    	query_posts("category_name=blog-post&posts_per_page=2" . '&order=dec');
    	if ( have_posts() ) : while ( have_posts() ) : the_post();
     	if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
    
    	<div class="entry">
            <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
            <div class="entrycontent"><?php
                global $more;
                $more = 0;
                the_content('Read more...'); ?>
            </div>
            <img src="" alt="whatever" />
        </div>
    
    	<?php endwhile; ?>
    
        <div class="navigation">
    		<div class="alignleft"><?php next_posts_link('&laquo;
    Previous Entries') ?></div>
    		<div class="alignright"><?php previous_posts_link('Next
    Entries &raquo;') ?></div>
    	</div>
    <?php endif; ?>
  2. bobbyadamson
    Member
    Posted 4 years ago #

    Resolved from http://wordpress.org/support/topic/331426?replies=3

    Replaced my query_posts with:

    <?php
    			$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    			$args = array(
    				'category_name' => 'blog-post',
    				'paged' => $paged,
    				'posts_per_page' => 3
    			);
    			query_posts($args);

Topic Closed

This topic has been closed to new replies.

About this Topic