tips,wordpress

Multipaging a single post using wp_link_pages

19 Jun , 2009  

Heya Fellow bloggers,

I won’t be saying again in this post that wordpress is an awesome blogging application, lol I said that again icon razz Multipaging a single post using wp link pages You probably are looking for any sort of plugin which may split your single post into multipaged post with a nifty pagination, right ? If I am correct then you are wrong, because you do not need any such plugin for that, wordpress has this feature built-in. This feature is known by very few and as a result we have long posts which are have really slow loading time on a browser, especially the ones with images, eg. My previous post , photoshop tutorials etc.

So how you go about that ?

WordPress has very nice quicktag called <!- -nextpage- ->(extra space is  given between – , for visbility, please chop off when you gonna type this), which will take care of all your pagination requirements inside a single post. So where you want the post to chop off and paginate to next page just insert the quicktag <!- -nextpage- -> and that is all required from you. But one things you need to make sure  is that your theme supports this post pagination feature. Generally themes do not take this feature in account as previously discussed that this is very rarely known tag used by bloggers.

Ok, I wanna see an example now

Well here is how this look in the screenshot and for live example, please visit my previous post about Install wordpress in local environment. You can change the CSS so as to match your theme.

post pagination Multipaging a single post using wp link pages

How do I make my theme compatible for this ?

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.

What after doing the above to steps the pagination won’t come ?

When I installed into my template files, the YARPP and Sociable plugins were reacting pretty bad. They just wont let the pagination to render, so i tried to disable two of them and realized it was being rendered then. I had to manually insert the code for YARPP , but as sociable’s manual insertion wasn’t available so had to shift the social bookmarking to Add to Any plugin. So do take care that you insert these plugins manually if you face any problem.

Hope that helps.

Happy Long Blogging !!
Sachin Khosla

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. Defaults to (blank). Version 2.7 or later required.
link_after
(string) Text that goes after the text of the link. Defaults to (blank). Version 2.7 or later required.
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. (Valid in WordPress 1.5 or after)
previouspagelink
(string) Text for link to previous page. Defaults to Previous page. (Valid in WordPress 1.5 or after)
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.

, ,


2 Responses to “Multipaging a single post using wp_link_pages”

  1. superstumped says:

    Actually, never mind. I got it to work. I don’t even think it had anything to do with my PHP commands, rather, I think it was the quick tag itself.

  2. Alex says:

    Great article! I have a question, though, and I don´t seem to be able to solve it… what if you want to use text instead of numbers? Some sort of inner index for a large post. For instance, let´s say you hace a huge post about how to use Photoshop, and you want to help readers to browse that post giving them a small index in every page of that post (“Introduction”, “Brushes”, “Techniques”, and so on).

    Thanks in advance!!!

More in tips, wordpress (134 of 159 articles)


Well this post is not for the regular RSS readers, but sure is for those nomads who look around how ...