0

I want to show the links to next and previous webpages from my directory. I searched on the web and found this

<?php 
$prev_post = get_adjacent_post('', '', true);
$next_post = get_adjacent_post('', '', false);
?>
<p><?php echo $prev_post->post_title; ?></p>
<p><?php echo $next_post->post_title; ?></p>

This is what I want to do, let's say I have three posts. sitename.com/current.php , sitename.com/previous.php , sitename.com/next.php If I am on current.php I want to show links of previous.php and next.php How can I do that?

Sheel Ranjan
  • 167
  • 3
  • 12
  • 1
    You would Google "php pagination". Are you wanting to use a database or not? – Funk Forty Niner Feb 19 '15 at 01:11
  • I want to show a complete post and then at the bottom of post the links to next and previous posts. How could I use pagination for this? – Sheel Ranjan Feb 19 '15 at 01:19
  • Google >>> pagination without database php - You can even find something using JS. – Funk Forty Niner Feb 19 '15 at 01:20
  • Do I need pagination even for showing one link? – Sheel Ranjan Feb 19 '15 at 01:21
  • I don't know, do you? You asked how to do pagination which that is what that piece of code does, so I answered. I also asked if you were wanting to do this with a DB or not; do you? http://stackoverflow.com/a/3857110/ base yourself on that. – Funk Forty Niner Feb 19 '15 at 01:22
  • Thank you. I think that will work If I set number of results per page to just one. – Sheel Ranjan Feb 19 '15 at 01:27
  • As per your edit: Google >>> "if current page php" - One result found http://stackoverflow.com/q/15717516/ see that Q&A's. Then http://stackoverflow.com/q/13032930/ and https://forums.digitalpoint.com/threads/php-if-url-is-homepage-then-do-this.499517/ those should get you started. – Funk Forty Niner Feb 19 '15 at 01:34

0 Answers0