tags:

views:

283

answers:

2

What happens?

I'm guessing that somehow the post or page is parsed before displaying, and then just split into two methods? I can't seem to find any documentation on how the underlying

<?php wp_link_pages( $args ); ?>

method actually works. Is all of this processing done before the user loads the concerned page? Or is it scanned and then stored separately inside the database?

A: 

from http://www.digimantra.com/tutorials/wordpress/multipaging-a-single-post-using-wp%5Flink%5Fpages/

Wordpress has a template tag called wp_link_pages() which is responsible for the pagination of the post. So you have to put this after the the_content() tag. As all other wordpress tags this again have few parameters which help you customize the function in very simple way. Here are the params as defined by the wordpress documentation.

before (string) Text to put before all the links. Defaults to <p>Pages:

after (string) Text to put after all the links. Defaults to </p>.

link_before (string) Text that goes before the text of the link.

link_after (string) Text that goes after the text of the link.

next_or_number (string) Indicates whether page numbers should be used. Valid values are:
* number (Default)
* next (Valid in WordPress 1.5 or after)

nextpagelink (string) Text for link to next page. Defaults to Next page.

previouspagelink (string) Text for link to previous page. Defaults to Previous page.

pagelink (string) Format string for page numbers.  % in the string will be replaced with the number, so Page % would generate “Page 1″, “Page 2″, etc. Defaults to %.

more_file (string) Page the links should point to. Defaults to the current page.
Kirk Hings
Yeah, but how does wordpress know how to divide the page? How does it scan the content of the page for the <!--nextpage--> tag, and then split the page into appropriate pages?
Simon
+1  A: 

WordPress uses the PHP explode function to split the content into a array of 'pages'. Happens in the setup_postdata function with this code:

$pages = explode('<!--nextpage-->', $content);

Michael