We’ve received a few queries about the next/previous link in our WordPress themes from people wanting to know how to implement it in their themes. Well, the answer is simply insert the posts_nav_link() template tag into the php files of your theme that has the if ( have_posts() ) : while ( have_posts() ) loop. These files include index.php and archive.php. When you use the posts_nav_link() tag the next/previous links are generated automatically when required. However, the tag only works for pages of posts.
So where do you insert the posts_nav_link() tag?
You insert it after the loop. In other words, after the <php? endif; > towards the bottom of the file.
If you want to find out more about the posts_nav_link() tag visit the following WordPress pages:
- http://codex.wordpress.org/Template_Tags/posts_nav_link
- http://codex.wordpress.org/Next_and_Previous_Links

Leave a reply