How to use numbers and next/previous links in post and page?

Posted by Prem Tiwari | Updated on

The function you’re using, wp_link_pages­Codex, does not have the feature you’re looking for by default.

However you can easily extend it by using a callback function, registered as a filter on that functions arguments:

The filter will then modify the parameters that are used in that function on-the-fly and inject the missing links to the prev and next arguments which are output on the left and right side of the numbered link list (next_or_number’ => ‘number’):

Usage:


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers