WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Next/Previous Links from Home Page Show Same Posts (16 posts)

  1. Edie Sellers
    Member
    Posted 6 years ago #

    I've spent waaay too much time getting my site working, and my last problem is really making me crazy.

    I needed a previous/next link at the bottom of my home page, so I added the following code to my index.php file:

    <?php endwhile; ?>

    <div class="navigation">
    <p class="previous"><?php next_posts_link('Previous Entries') ?></p>
    <p class="next"><?php previous_posts_link('Next Entries') ?></p>
    </div>

    Now I've got next/previous links, but from the home page it doesn't change the posts on page 2, it just redisplays the same posts from the main page.

    It works fine on the Archives page, however.

    I'm using PressRow template, if that helps at all.

  2. Edie Sellers
    Member
    Posted 6 years ago #

    BTW, I saw lots of others having this problem on this forum, but I didn't find a resolve.

  3. kilerb
    Member
    Posted 6 years ago #

    Having this exact same problem. The weird part is I have wordpress 2.3.3 installed on my site in 2 folders. My main page shows 6 stories just like i tell it to. Then when i hit next it does not show 7 and beyone, it shows 1-6 again but the option at the bottom changes from "next" to "previous"

    My other page "blog" works perfectly though. Why can't i see more stories on my main page when people hit "next?"

    Thanks...

  4. kilerb
    Member
    Posted 6 years ago #

  5. Edie Sellers
    Member
    Posted 5 years ago #

    Actually, that support thread you linked to didn't really help me, as my index.php doesn't contain a "<?php if (is_home())" script.

    Although searching through it did help me fix another bug having to do with not displaying more than three posts on the front page... so it wasn't a total loss.

    Anyone else have any advice?

    Here's a link to my index.php script:

    http://WWW.sprocketscientists.com/weblog/archives/gamehoundsIndexphp.txt

  6. Edie Sellers
    Member
    Posted 5 years ago #

    A-ha!!

    Figured it out!!

    I had a section that contained the following:

    <?php query_posts('showposts=10'); //displays X number of posts on the page ?>

    As you can see, no "is_home" section. But I replaced that string with:

    <?php
    if (is_home()) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=-3&paged=$paged");
    }
    ?>

    And now the number of displayed posts AND the previous/next links not working.

    Thanks everyone. Took me a while, but finally it's done!!!!

  7. indragm
    Member
    Posted 5 years ago #

    Could you help with mine? I can't get mine to work, it keeps displaying the same post. Same problem, but in my index.php, can't find any if(is_home()).. code.

    Index file can be seen here
    http://rapidshare.com/files/147106061/index.php.html

  8. indragm
    Member
    Posted 5 years ago #

    oh, nvm.. figured it out. Thanks anyway

  9. relequestual
    Member
    Posted 5 years ago #

    Hi. Im trying to implement this fix, however im having problems.
    any help. please check http://wordpress.org/support/topic/206625
    thanks

  10. peteraltenberg
    Member
    Posted 5 years ago #

    The next and previous are showing up now and I'm using this is_home bit of code but still I'm getting the same posts every time, no previous posts. Any help? Could it be my link code:

    <div class="navigation">
    <div class="alignleft"><?php posts_nav_link('','','« PREVIOUS PODCASTS') ?></div>
    <div class="alignright"><?php posts_nav_link('','NEXT PAGE »','') ?></div>
    </div>

  11. boosey12
    Member
    Posted 5 years ago #

    It seemed to fix itself!!

    [sig moderated]

  12. peteraltenberg
    Member
    Posted 5 years ago #

    Hmmm. Mine didn't fix itself. How does the fix itself thing happen, after time, after sacrificing an animal? Can you show me what the code you have that works for you? (nice iphone hack site, I have to upgrade mine.)

    Thanks.

  13. peteraltenberg
    Member
    Posted 5 years ago #

    Could you please show how you are using the prev/next links in your code? It's nice that yours started working but mine hasn't and looking at your working site doesn't really help me in any way solve the problem why mine doesn't work.

  14. maviefol
    Member
    Posted 5 years ago #

    GamerEdie, you are a genius! I've been looking for a fix for this for a couple weeks. And, btw, this is the only time I've ever actually found a solution on this forum.

    For anyone still with questions, here's the codes I used:

    <div id="nextprevious">
    <div class="alignleft"><?php posts_nav_link('','','&laquo; PREVIOUS ENTRIES') ?></div>
    <div class="alignright"><?php posts_nav_link('','NEXT ENTRIES &raquo;','') ?></div>
    </div>

    this goes right above your </div></div> <!-- Closes Content -->
    in your INDEX.php file

    Now, in order to get the previous/next links to bring up previous, next correctly (in pages, not just the same front page) you need to add GamerEdie's code above which I cut and pasted here again to make it easy:

    <?php
    if (is_home()) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=-3&paged=$paged");
    }
    ?>

    Make note! see where it says "cat=-3 ??? that -3 means you are telling it NOT to bring up cat 3. If you want to replace that number replace it. If you need to hide other cat's just add a coma, minus sign and the next number (i.e. ("cat=-560,-4,-43&paged=$paged") )

    Also note, the above code replaces the is home thingy in your index.php file that is there already, IF this isn't already the code in there.

    Thanks to everyone for continuing to post on this question! I'm sure you've all helped a lot of people (I'm just one of them)

  15. CristianRa
    Member
    Posted 5 years ago #

    Have had similar problems on my blog foam board insulation site for quite a while, but with the help of this thread I was able to solve it.

    Thanks @ maviefol.

    Best of luck,
    Jason Carter.

  16. midnight_focus
    Member
    Posted 5 years ago #

    I go the same problem on my blog

Topic Closed

This topic has been closed to new replies.

About this Topic