WP - get the last page of multiple pages
I could not find any description in the Wordpress docs how to get the last page, if the page content is divided to more than one page.
So I found in the Internet the following php script which solves the problem:
In "query.php" (wp-includes/query.php) there’s a function called "setup_postdata()" in which WP initializes global variables for post data. Since these variables are "global" they’re accessible outside of the "setup_postdata()" function.
function mish_wp_get_last_page()
{
global $page, $numpages, $multipage;
if ( $multipage )
{
$last_page = false;
if ($page == $numpages)
{
$last_page = true;
}
}
else
{
$last_page = true;
}
return $last_page;
}
take a look at: