Thanks, TSGuitar.
Thank you for figuring that out. I appreciate it. I didn’t try that method because there were two things I didn’t like: First, it isn’t adaptable to anywhere outside the loop; you can’t, say, use it in the page title. Second, I don’t want the current page number linked to itself.
Instead, I put the subject on the back burner for a while and let my subconscious chew on it. Ultimately, the solution came to me, which I turned into a plugin (I’ll release it officially at some point in the near future):
<?php
/*
Plugin Name: PSB Paged Posts Number
Plugin URI:
Description: Adds a tag to display the current page number of multi-page posts (for example: in the post title, the page title, or wherever).
Author: Pariah S. Burke
Version: 0.1
Author URI: https://www.iampariah.com
*/
function psb_pagednumber()
{
global $wp_query;
if ((($page = $wp_query->get("paged")) || ($page = $wp_query->get("page"))) && $page > 1) {
echo ' PAGE '.$page . '';
}
}
?>
With that plugin activated, open single.php and/or index.php, find the following line:
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
And insert this immediately after it:
<?php if(function_exists('psb_pagednumber')) { psb_pagednumber(); } ?>
Now, if the post is NOT multipage, nothing will happen. If the post IS multipaged, the title will be appended with “Page X”–but only AFTER the first page of the post. So, you’ll never see “My Post Page 1”; just “My Post Page 2,” “My Post Page 3,” and so on.
It’s a great cue to readers who come into a post after the first page, which is pretty common with traffic from search engines.
The plugin call can also be inserted into the HTML page title like so:
<title><?php if(is_single()) { ?><?php wp_title(''); ?><?php if(function_exists('psb_pagednumber')) { psb_pagednumber(); } ?> — <?php } ?><?php bloginfo('name'); ?></title>