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.

1
1

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";

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *