Pagination for WordPress Posts – Multiple Pages for Posts

When you have a lengthy post in your WordPress blog that you wish to separate into multiple pages, WordPress has built-in pagination that you can use (although it's somewhat hidden in some themes).

For mine, I needed to add the php link_pages / php wp_link_pages function code and the quicktag (<!–nextpage–>).

For details on usage and how to implement the paginate feature on your WordPress weblog, see:
php link_pages()
and
php wp_link_pages()

The function's basic usage is:
<?php link_pages('what should be before…a paragraph break perhaps…<p>', 'then close your paragraph break after </p>', 'do you want next effect or page numbers', 'if next what should next link say', 'and what should previous link say', 'Page % here will show Page 1 where % is replaced by the page number', 'where should links go…leave blank for current'); ?>

Here's an example using next and previous page links:
<?php link_pages('<p>', '</p>', 'next', 'go to next page', 'go to previous page', ", "); ?>

Here's another example using page numbers:
<?php link_pages('<p>', '</p>', 'number', ", ", 'Page %', "); ?>

Once you add the above code to the loop, you'll need to use the <!–nextpage–> quicktag to call it in your longer posts where you want them to be split into pages.

Upon doing so, you should see navigation links inserted at that point in your post.

The pagination function is used in long articles on this site. Bounce around and you'll see them. For example, this article uses it.

One other thing…

I needed to include some more code along with the php link_pages code as my WordPress theme does not have a single.php file. It uses the index.php file. If your WordPress theme uses the index.php file and does not have a single.php file, add the following right before the php link_pages code:

<?php if ( is_single() ) { ?>

 

The above is all based on WordPress 2.0.x.

 

—— Now, all of this being said, I am NOT a programmer. Use at your own risk. The above is offered with no guarantee. If you need assistance, please visit the WordPress forums.



 
Google Search