Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

Thanks!

share|improve this question
    
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. –  Chip Bennett Oct 4 '11 at 12:53
add comment

2 Answers

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.

share|improve this answer
    
Look my edit, thanks! –  Muazam Aug 28 '11 at 16:57
    
Are you sure you are placing it in the correct page template? –  Jeremy Jared Aug 28 '11 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). –  Jeremy Jared Aug 28 '11 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 '11 at 21:50
add comment

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); ?>

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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