wp_link_pages

POST LINK TAG

What It Does

Displays the links for paginated posts. wp_link_pages must be used within The Loop.

Code

<?php wp_link_pages(‘parameters’); ?>

The available parameters are as follows:

before

What text to display before all the links. By default, the following HTML is used:

<p>Pages:

after

What text to display after all the links. By default, the following HTML is used:

</p>

link_before

What text to display before each link. This feature is only available in WordPress versions 2.7 and above.

link_after

What text to display after each link. This feature is only available in WordPress versions 2.7 and above.

next_or_number

Allows you to choose whether to use a “next” link, or to use page numbers.

  • number – Displays page numbers (default value)
  • next – Displays a “next” link

nextpagelink

Anchor text to use when linking to the next page. By default, “Next page” is used.

previouspagelink

Anchor text to use when linking to the previous page. By default, “Previous page” is used.

pagelink

Allows you to customize the format in which the page numbers are displayed. The “%” symbol is used to signify the actual page number. By default, “%” is used.

more_file

Which page the links should point to.

Example

<?php wp_link_pages(‘before=<p>&after=</p>&pagelink=Page no. %’); ?>

The above example would display the pages in paragraph tags, with the page link displaying as “Page no. %”, where “%” is the actual page number.