I can't get get_next_posts_link to work. shouldn't his code work?

<?php echo  get_next_posts_link(); ?>

Well, I am trying to get next 5 posts, any idea how?

EDIT: Accroding to:

<?php next_post_link('<strong>%link</strong>', '%title', TRUE); ?>

Should show me a link to next post in the same category, when I do this nothing is shown. And I do have posts in the category.


  • Can you post your actual code? Correct functioning of some template tags depends on their location with respect to the Loop. Without seeing where/how you're using this template tag, it is difficult to provide specific advice. Oct 4, 2011 at 12:53

2 Answers 2


Use this for a link to previous posts with directional arrows:

<?php previous_post_link(); ?>

Or this for a link to previous posts that without "<<":

<?php previous_post_link('<strong>%link</strong>'); ?>

The code needs to be inside the loop.

  • Are you sure you are placing it in the correct page template? Aug 28, 2011 at 20:08
  • It probably needs to go in the archives.php. If that doesn't do it, you should try adding it to archives.php, single.php, category.php, etc... If you want to be sure you are in the right template, you can try this trick to show the template being used: snipplr.com/view/58255/… . You will see the current template being used in the admin bar at the bottom of your screen (make sure the admin bar is set to show when viewing site). Aug 28, 2011 at 20:19
  • I should have mentioned that I need this in single.php Sorry. The code you gave me works, but it shows other categories as well. I want it show only one category.
    – Muazam
    Aug 28, 2011 at 21:50

If you would have taken the effort to look in the Codex, you would have seen that it works like: <?php previous_post_link('%link', 'Previous in category', TRUE); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.