Forums

Previous & Next links to show on index.php (26 posts)

  1. tyh
    Member
    Posted 4 years ago #

    Hi,

    When I go to my site (ayutheos.uni.cc/vf/) the links to go to previous/next posts are not showing. However they are shown in individual posts (eg. http://ayutheos.uni.cc/vf/archives/2005-05-10/for-grandma). Am not using home.php or single.php templates. Have tried using home.php with exact codes as index.php but no go. Is there some difference between index.php and individual posts in terms of templates?

    FYI, have just upgraded to WP 1.5.1. Problem wasn't there prior to upgrading. Am thinking if there's something to do with the upgrade...

    Am using
    <?php previous_post('%', 'prev . ', 'no'); ?><?php next_post('%', 'next . ', 'no'); ?>
    to go to previous single post. Don't want to use posts_nav_link as that goes to 2nd page of site.

    Any help is appreciated.

  2. Lorelle
    Member
    Posted 4 years ago #

    I know it's confusing and it took me a while to figure things out, but this is the instructions for the previoux_post()

    Used on single post/permalink pages, this tag lists the previous post in chronological order from the current post...

    So next and previous work on single post pages not Looped index.php type pages (search, category, things that have more than one post showing.)

    For multiple post pages like search, archives, category and so on, posts_nav_link() is the one to use.

    You can use both if you want, or just let it stay like it is. Lovely site.

  3. tyh
    Member
    Posted 4 years ago #

    So how do I put a link on the main page to go to the previous single post? Do I use the permalink for previous post?

    Thanks for your comment on site! Am really enjoying posting to new site using WP, having previously used MT.

  4. Lorelle
    Member
    Posted 4 years ago #

    I believe that if you have the Admin > Options > Read set to show only one post on the front page, the nav link would take you to the next post chronologically, in the past.

    Even through there is only one post on the front page, WordPress "thinks" there could be more than one, so that needs a different next/previous kinda tag. That's what I get from going through the template tag information. That's why there are two types.

  5. tyh
    Member
    Posted 4 years ago #

    Yes, but then the link would show ayutheos.uni.cc/vf/page/2. Would like to get the link to link directly to the previous individual post.

    Would there be a way to get permalink for the post before eg. <?php the_permalink( current post - 1 ); ?> ?

  6. Lorelle
    Member
    Posted 4 years ago #

  7. roro
    Member
    Posted 4 years ago #

    I have the same problem!
    just after upgrading to 1.5.1

    In the archives the links work good but not in home

  8. tyh
    Member
    Posted 4 years ago #

    Hmm..that doesn't seem to help, but thanks for the link though Lorelle.

    To clarify things a bit, instead of previous link showing "mysite.com/page/2" I want it to show "mysite.com/permalink/to/previous/post"

  9. Axo1ot1
    Member
    Posted 4 years ago #

    Your theme is totally awesome! I've been looking for something like that for a comic I'm drawing and want to put on the web. Have any interest in sharing it?

  10. tyh
    Member
    Posted 4 years ago #

    Thanks Axo1ot1. It's actually a very basic stripped-down theme, modified from the classic theme. Took out out sidebar, using custom posts per page plugin to show 1 post, thumbnail archives using excerpts, a modified upload code available at blueblurry.com. And that's it. :)

    Am still very much a beginner at using WP, though this forum is a great place to get help from more experienced users.

    Anyone else have a solution to my problem? Is it possible to show permalink to previous post in the index page?

  11. roro
    Member
    Posted 4 years ago #

    Someone!

  12. jpr
    Member
    Posted 4 years ago #

    I have the same problem after upgrade to 1.5.1, reverted back to 1.5 for the time being. It would be nice to have a solution for this without resorting to hacking PHP. I tried using the get_posts function, but it seems like a bit much for just displaying the previous post on the index page.

  13. roro
    Member
    Posted 4 years ago #

    Someone has tried 1.5.1.1 ?

  14. Lorelle
    Member
    Posted 4 years ago #

    Getting back to the issue at hand, I believe that you just need to set your permalinks and update your htaccess file from the Options > Permalinks page. Then it should work fine.

    And a lot of people have tried 1.5.1 but the issue is with permalinks needing updating.

  15. charbyte
    Member
    Posted 4 years ago #

    <?php previous_post('&laquo; &laquo; %', 'Previous', 'no'); ?>
    <?php if ( is_single() ) { ?>| <?php next_post('% &raquo; &raquo', '', 'yes'); ?>
    <?php } ?>

    Not sure if this is what you're looking for.. it works for me by going to the previous post with the perm link. but I'm still only testing on 1.5 , Will attempt to upgrade my test site to 1.51. and see if this still works. It checks to see if this is a single post and grabs the next.. also NEXT doesn't show up on the index page.

  16. charbyte
    Member
    Posted 4 years ago #

    Okay I just looked at your site and I doubt what I posted is what you're looking for .. sorry. Although I do like the layout very nice! one small suggestion, you can use a link on the secondary pages back to home base. I realized I was in the middle of your site and wanted to go to the beginning.

  17. jpr
    Member
    Posted 4 years ago #

    charbyte: I use similar code which does in fact work in 1.5 (highinfrequency.com) but not in 1.5.1. After re-reading the documentation for previous_post(), this appears to be the expected behavior. But I don't see an obvious way to put the permalink to the previous post on the index page :( I tried get_permalink(the_ID - 1), but that failed. Even if it had worked, that is not the ideal way to get the link, it is possible that the the_ID() - 1 could point to a page that has not been published yet.

  18. tyh
    Member
    Posted 4 years ago #

    Yes, previous_post/next_post worked when I was using 1.5, but not when upgraded to 1.5.1.

    At index.php I've used both <?php posts_nav_link('','','previous .'); ?> (showing the word 'previous') and <?php previous_post('%', 'prev . ', 'no'); ?> (showing the word 'prev'), and only one of them comes up - post_nav_link when at main site, previous_post when at single post.

    There is a link back to the homepage - clicking on the site title at the top will bring you back to the beginning. :) Guess didn't make the link back home more obvious.

    Lorelle, my permalinks are working fine. Have updated them, as suggested but that doesn't solve the problem.

  19. jpr
    Member
    Posted 4 years ago #

    Just tried 1.5.1 and it does not work there either. Bummer.

  20. jpr
    Member
    Posted 4 years ago #

    I did a quick workaround which I'm using in my index.php template. The explaination and code are on my blog.

  21. roro
    Member
    Posted 4 years ago #

  22. jpr
    Member
    Posted 4 years ago #

    Yup, blueblurry's fix works like a charm.

  23. charbyte
    Member
    Posted 4 years ago #

    Yes I tested it out and it works fantubulous thanks BlueBlurry. Going to use this live ... one of these days :d

  24. mperron
    Member
    Posted 3 years ago #

    Can anyone post the Blueblurry fix? The site seems down and I can't find the code anywhere.

  25. ladydelaluna
    Member
    Posted 3 years ago #

    i second mperron's request - albeit a month later...

    i'm in dire need of a prev/next fix for the vesuvius theme... running on wp 2.0.1 :(

  26. realblanka
    Member
    Posted 3 years ago #

    In wp 2.0.x, I was having a similar issue also. To get the raw url for the previous post, I used something like the following (in index.php):

    <?php global $wp_query; $wp_query->is_single = true; ?>

    <a href="<?php echo get_permalink(get_previous_post()); ?>">PREVIOUS POST</a>

    <?php endwhile; ?>

    I think what this does is 'trick' the index page into thinking that its a single post.

    There are too many damn variations of previous* and next* in the wp codebase. The docs need some serious cleaning up.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags