开发者

How does the WordPress <!--nextpage--> tag actually work?

开发者 https://www.devze.com 2022-12-10 18:55 出处:网络
What happens? I\'m guessing that somehow the post or page is parsed before displaying, and then just split into tw开发者_StackOverflowo methods? I can\'t seem to find any documentation on how the un

What happens?

I'm guessing that somehow the post or page is parsed before displaying, and then just split into tw开发者_StackOverflowo 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?


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);


from http://www.digimantra.com/tutorials/wordpress/multipaging-a-single-post-using-wp_link_pages/

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.
0

精彩评论

暂无评论...
验证码 换一张
取 消