Wordpress' Built-in Category and Single post Navigation
For navigating to older and newer posts from a single post page, Wordpress gives us some useful functions like previous_post_link() and next_post_link(). Those are easily confused with the similar looking functions, previous_posts_link() and next_posts_link(), used for navigating between pages listing multiple posts, in a category for example. Wordpress gives us the category structure. We can use categories and permalinks to easily organize our posts. This means we can access our posts in the fictional category named "foo" by visiting the following URL:
http://yourdomain.com/category/foo
And if the number of posts in your category exceeds the number of posts allowed per page ( specified in Settings -> Reading ), the URL becomes
http://yourdomain.com/category/foo/page/2
Navigating multiple pages, each with multiple posts
Not all of your posts will fit on a single page if you have many posts in a category and your Wordpress settings limit the number of posts per page. If you have ten posts in the press category, and you're settings are two posts per page, the posts in the press category will be spread over 5 pages. To create the navigation links between pages of posts in a category, we can use posts_nav_link(),  or for more control you can use the individual previous_posts_link() and next_posts_link(). Each of these functions takes options to customize the text of the previous and next buttons, or you can call it with no arguments. e.g.,
The default function with no args will produce something like: « Previous Page     Next Page »
Navigating between single posts
On a page that shows a single post, we can create previous and next buttons to get to the next single post. The previous and next buttons in this case will lead to the user to a full post, not a page with multiple posts. We can create these buttons using previous_post_link() and next_post_link(). e.g.,
%link','Previous: %title',TRUE); next_post_link('%link','Next: %title',TRUE); ?>
Would produce: Next: Post Title of your Post
Paginating a Single Post or Page
Have a really long page or blog post? Wordpress also lets you spread a single page or blog post over several pages. The built in function called nextpage will automatically separate your content into pages where ever you place the tag. Nextpage is a Wordpress Quicktag, similar to more. Unlike the more quicktag, nextpage is not available by default in Wordpress version of TinyMCE. We can easily add a button for "next page" to the Wordpress editor by using a plugin. I used NextPage Buttons. To get wordpress to properly display the pages and page numbers on single blog posts or pages, you need to use the wp_link_pages() function inside the loop on page.php or single.php, e.g.,
'
Pages: ', 'after' => '
', 'next_or_number' => 'number')); ?>
















