WP - get the last page of multiple pages

Keine Antworten
Christian Gnoth
User offline. Last seen 3 Jahre 6 Wochen ago. Offline
Beigetreten: 03.04.2009

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:

Get the Last Page of a Post in Wordpress