Try the next_post_link() function.
Thread Starter
bbp
(@bbp)
Thanks for your reply.
I can’t use it on the homepage, or at least I didn’t succeed to use it. In a second time I could use it, but my problem is to use this kind of function on the homepage.
Any new idea?
Can you explain in more detail what you are trying to do? I can get the next_post_link() working just fine. I must be missing something.
Thread Starter
bbp
(@bbp)
Well I’m still a newbie, maybe I miss something, but next_post_link() works on a post, not on the index. It’s exactly the behaviour what would like, but straight away from the index. If you use next_post_link() on the index nothing appears.
I’m trying to achieve the same effect to for my homepage (home.php) template: I want to display only the latest post on the homepage, but allow the user to go back one post at a time chronologically. Unfortunately, the previous_post_link only works in permalinked pages (single.php):
http://codex.wordpress.org/Template_Tags/previous_post_link
Does anyone know if there is a way around this: to get the previous_post_link function to work on home.php.
Also, if there is another way to rethink this problem, I’m open to suggestion!
This is not a direct solution to the previous_post_link problem, however, if you have set up a homepage with the latest post, there is a way to have the latest post *be* the homepage url/permalink. Use just this code in home.php:
[?php
query_posts($query_string.’&posts_per_page=1′);
the_post();
wp_redirect(get_permalink(), ‘302’);
return;
?]
@marc0047
I was trying something similar and your code worked beautifully. Thank you very much.