WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] "older entries" link not working (3 posts)

  1. an90278
    Member
    Posted 1 year ago #

    I see that many people are having the similar issue, but I could not find a solution for my issue.

    The link is working correctly, but I keep seeing the latest blog page (basically page doesn't change) and it doesn't go to page 2.
    Here is what I have in nav.php

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

    and here is what I have in blog template:

    <?php get_header();
    $cat = is_home() ? '&cat=-42' : '';
    if( ! ( $paged = get_query_var('paged') ) ) $paged = 1;
    query_posts( $query_string . '&posts_per_page=3&paged=' . $paged . $cat);
    ?>

    I'd appreciate it if someone could please suggest what I can do to solve this issue!

    Thanks.

    [Moderator Note: Please post code or markup snippets between backticks or use the code button.]

  2. vtxyzzy
    Member
    Posted 1 year ago #

    You should check to see if $paged is being set correctly. Change your code to this:

    <?php get_header();
    $cat = is_home() ? '&cat=-42' : '';
    if( ! ( $paged = get_query_var('paged') ) ) $paged = 1;
    print_r("<p>PAGED:$paged</p>");
    query_posts( $query_string . '&posts_per_page=3&paged=' . $paged . $cat);
    ?>

    and see if $paged is set to anything other than 1. If not, you may need to use the 'page' query_var rather than 'paged'.

  3. an90278
    Member
    Posted 1 year ago #

    Thank you, now it is working.

Topic Closed

This topic has been closed to new replies.

About this Topic