Link Tags are the most powerful tools you ever found for moving your visitors in and around your WordPress website. The idea to use the Next and Previous post links guide your visitors throughout your site. Understanding the process well, there are two sets of tags which lets the process happens: posts_nav_link() and the combination pair of previous_post() and next_post(). The posts_nav_link() will displays both the Previous and Next links while the combination pair will display one of the Previous or Next links.
Understanding The posts_nav_link()
The first set is featured only on the non-single/non-permalink web pages, which includes categories, archives, searches and the index pages. The template tag posts_nav_link() build two links at the page bottom within the WordPress Loop to display the next and previous pages. By default, the posts_nav_link looks like this:
« Previous Page — Next Page »
To lookout for the tag, check out in either a paragraph code or a division:
1 |
<div class="navigation"><p><?php posts_nav_link(); ?></p></div> |
While the parameters of the tag are as follows, where these parameters can be used to generate a string or any text or HTML or CSS tags:
1 |
<?php posts_nav_link('separator','prelabel','nextlabel'); ?> |
Understanding The Next and Previous Posts
The next and previous post links can be located at the bottom of your single/permalink post; will let directing the user to move to the next or previous post in chronological order. The template tags are previous_post() and next_post().
The default usages of these tags are:
1 |
<?php previous_post(); ?> <?php next_post(); ?> |
While it looks like this:
previous post: Link To Previous next post: Link To Next
Photo Credit: Flickr/Dave O