WordPress.org

Ready to get started?Download WordPress

Forums

next_posts_link showing same posts as Page 1 (2 posts)

  1. deniseyap
    Member
    Posted 6 months ago #

    Hiya,

    I've been having some trouble with pagination.

    I use a Page-template to display 10 posts per page from 1 particular category. Everything is working fine, except that when I click on "Older Entries", the page refreshes to /news/page/2, but the posts that are on the page are exactly the same posts as the ones one /news (i.e. page 1).

    I have been troubled by this for days, read a lot of the codex and other posts on the topic, but I simply cannot figure it out!

    If it's important at all my permalinks are set to /%postname%/. Any help or pointing in the right direction is WONDERFULLY APPRECIATED!

    Please tell me it's not an error with a missing semi-colon...

    Here is my code:

    <?php
    /*
    Template Name: News
    */
    ?>
    <?php get_header(); ?>
    <style type="text/css">
    #phogallery .post ul li {
    color: #b30838;
    font-weight: normal;
    }
    </style>
    
    <div id="phogallery">
    <?php get_sidebar(); ?>
    
    <div class="post">
    
    <ul>
    <li>latest news</li>
    </ul>
    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
    
    <?php
    $args = array(
    	'cat' => '66',
    	'orderby' => 'date',
    	'order' => 'DESC',
    	'posts_per_page' => '10',
    	'paged' => '$paged'
    );
    
    query_posts( $args ); ?>
    
    <?php if ( have_posts() ) : while (have_posts() ) : the_post(); ?>
    <ul>
    <li><a href="<?php the_permalink() ?>"><pre><?php the_title() ;?></pre></a></li>
    <li><a href="<?php the_permalink() ?>"> <?php the_post_thumbnail(array (580, 580)); ?></a></li>
    <li><?php the_excerpt(); ?></li>
    </ul>
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <?php endwhile; ?>
    <?php
    next_posts_link( 'Older Entries', $post->max_num_pages );
    previous_posts_link( 'Newer Entries', $post->max_num_pages ); ?>
    <?php wp_reset_postdata(); ?>
    <?php endif; ?>
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    </div>
    </div> 
    
    <?php get_footer(); ?>
  2. vtxyzzy
    Member
    Posted 6 months ago #

    Try removing the quotes around $paged here: 'paged' => '$paged'

Reply

You must log in to post.

About this Topic