Lion Lion

December 20, 2016

Mufasa

The Next and Previous post links guides your visitor through your WordPress site. When it comes to creating strong site-wide navigation, some of the most powerful tools for moving your visitor around are these link tags.

There are two sets of tags that move the visitor through your WordPress site: posts_nav_link(), which displays both the Previous and Next links, and the combination pair of previous_post() and next_post(), which each display one of the Previous or Next links. This article will look at how these two tag sets work.

Note: “Previous” and “Next” in this case refer to posts in the order that they are in, not to any particular direction in time. This often confuses many people, as WordPress, by default displays posts starting from the newest and proceeding backwards in time. Using this default ordering, “Next” would be moving backwards in time, because the “Next” page after page 1 would be page 2, and that would move to older posts. If the post ordering is changed (like via a manual usage of query_posts in a template), then the links will point in different directions. This codex article uses both methods without explanation, because it is example code only. So it is important to keep in mind that the function is referring to an order that is independent of chronological time.