How To Show Next and Previous Post Below Comment Box

ADVERTISEMENTS

If you notice, you can see my previous and next post just below the comment box. I’ve used it to decrease the bounce rate and keep my readers on my blog for a longer time. Have a look :

prv

In todays article I am going to tell you, how to display these previous and next post, at the bottom, below comment box. Lets start :

1. Always remember that when we open any article, that page is the single.php file. In this tutorial also, we have to make changes in this file only.

2. In your theme, open single.php file and search for the following code.

<?php comments_template(); ?>

3. Now, enter the following code, just below it.

<div class=”nextprv”>

<div class=”alignleft”><?php previous_post_link(‘&laquo; %link’) ?></div>
<div class=”alignright”><?php next_post_link(‘%link &raquo;’) ?></div>

</div>

4. Now, save your work and you’re done.

5. Now, open any post and you will see previous post in the left hand side and next post in the right hand side. To make these posts look more attractive we’ll change the size of the fonts. What we will do is, we will create a new class in style.css file.

6. Open style.css file and paste the following code at the last.

.nextprv {
font-size: 14px;
margin: 20px 5px 0px 5px;
padding: 2px 5px 17px 5px;
border-top: 1px solid #CFE4F2;
}

Note : If you want to increase or decrease the font size, change the font-size attribute from 14 to any number you want. As the number increases, the size increases and vice-versa.

7. And finally, you are done !

Troubleshooting

If you are facing any kind of problem, kindly download the code from here.


If you like this post, you will love these :

  1. How To Show Only Post Titles In Blog Archives : Blogger Hack
  2. How To Create Recent Comment And Recent Post Widget Using Feedburner : Series 1
  3. How To Add Gravatar Beside Each Post In Wordpress
  4. How To Add Gravatar Beside Post Title In Blogger : Tutorial
  5. How To Manually Add BreadCrumbs To Your Wordress Blog
  6. 20+ Codes and Hacks Every Wordpress User Should Know
  7. How To Display Author’s Profile/Bio In Wordpress Blog

Gaganpreet Singh on December 8, 2009 | Filed Under Wordpress

{ 7 comments… read them below or add one }

1 George Serradinho December 8, 2009 at 11:14 am

A simple and yet easy customization to add to ones theme. It also helps the users see that there was a previous or next post.

Reply

2 Blog4Boys December 8, 2009 at 3:55 pm

Thanks for sharing the post. I am in need of this code.

Reply

3 Dan* December 8, 2009 at 8:52 pm

hey buddy i have seen ppl using in blogspot as well….. do u know how to do it in blogger ??

Reply

4 Gaganpreet Singh December 9, 2009 at 6:50 am

sure, i’ll write a tutorial on it soon.

Reply

5 bee December 8, 2009 at 11:11 pm

nice trick…

Reply

6 anshul December 11, 2009 at 3:06 am

how to do it in blogger ??

Reply

7 kissmo December 12, 2009 at 7:13 am

This will help to work with my blog..Thanx guys..

Reply

Leave a Comment

Previous post:

Next post: