WordPress.org

Ready to get started?Download WordPress

Forums

issue with next_posts_link reloading same content as homepage (11 posts)

  1. lilwillie
    Member
    Posted 3 years ago #

    When I click Previous Page or Next Page, the URL reads http://mydomain.com/page/2/ but the contents look identical to http://mydomain.com.

    Judging from reading about other users with similar problems, my first theory is: there's an issue with my permalinks interfering with my next_posts_link, previous_posts_link functions. Second theory: a mod rewrite issue.

    home.php looks like this:

    <div id="homecontentnav">
        <div id="prevLink"><p><?php previous_posts_link(); ?></p></div>
        <div id="nextLink"><p><?php next_posts_link(); ?></p></div>
    </div>

    And the URL the function spits out looks like: http://mydomain.com/page/2/

    "Front page displays" = Your latest posts

    "Blog pages show at most" = 10, but only 7 posts ever appear on the site - the 7 most recent posts, even if I click Next Page.

    permalink structure is custom = /%postname%/

    Any ideas would be appreciated, thanks!

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    link to your (real) site?

    does your front page template use any custom query?
    without the 'paged' parameter?

    "Blog pages show at most" = 10, but only 7 posts ever appear on the site - the 7 most recent posts

    this is weird, i would either expect that it shows 7 post, but no 'next-posts-link', or it shows the 10 posts and the link.

  3. lilwillie
    Member
    Posted 3 years ago #

    home.php:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    ...I'd prefer not to link to the real site in a public forum, but I can provide any more details you need if it would help.

    Thanks

  4. lilwillie
    Member
    Posted 3 years ago #

    here's the code again in pastebin:

    http://pastebin.com/kws3Tdns

  5. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    you could try and add:

    <?php wp_reset_query(); $paged = get_query_var('paged'); ?>

    before this line:

    <?php query_posts(array("post__not_in" =>get_option("sticky_posts"),"posts_per_page"=>6,"paged"=>$paged,"offset"=>1)); ?>
  6. lilwillie
    Member
    Posted 3 years ago #

    @alchymyth - I tried that. No dice. Thanks for the suggestion though.

  7. esmi
    Forum Moderator
    Posted 3 years ago #

    I'd also suggest that you use wp-reset_query(); between the two Loops.

  8. esmi
    Forum Moderator
    Posted 3 years ago #

    You also need to place the first Loop inside an !is_paged() conditional - otherwise it will fire on every page instead of just the first page.

  9. lilwillie
    Member
    Posted 3 years ago #

    Thanks, esmi - what is the syntax for an !is_paged() conditional?

  10. esmi
    Forum Moderator
    Posted 3 years ago #

    <?php if( !is_paged() ) :?>
    [ do stuff on the first page only here ]
    <?php endif;?>

    http://codex.wordpress.org/Conditional_Tags

  11. lilwillie
    Member
    Posted 3 years ago #

    add wp-reset_query(); between the two loops: check!

    put first loop inside !is_paged() conditional statement: check!

    ... still same problems as described in original post.

    thanks for the suggestions though.

Topic Closed

This topic has been closed to new replies.

About this Topic