WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom post type that I want to display the page you are on and how many pages total in this manner "Page 3 of 5" (meaning you are on page 3 of a 5 page post). These don't have to be links, just plain text numbers.

I'd still like to keep the standard function of the wp_page_links parameter "next_or_number" set to "next", but add this other page indicator.

I've tried experimenting with making my own funciton with some of the variables in the wp_page_links function on line 567 of the post-template.php file but I didn't get anywhere.

share|improve this question
up vote 6 down vote accepted

The current / total page count is set up by setup_postdata() which runs at the beginning of the loop. So, if you're in the loop, all you have to do is this:

global $page, $numpages;
echo "Page $page of $numpages";

If you need to do that outside of the loop, do this first:

global $page, $post, $numpages;
// This next line is optional: sets a new global $post variable
$post = get_post(123);
echo "Page $page of $numpages";
share|improve this answer
Worked like a charm. Thanks! – matt Dec 10 '10 at 2:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.