Display “Page 3 of 5” for a paginated post

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);
setup_postdata($post);
echo "Page $page of $numpages";

Leave a Comment