Skip to content

Instantly share code, notes, and snippets.

@sudar
Last active June 18, 2016 06:11
Show Gist options
  • Save sudar/7e7d8988201775d53103bffb34dad039 to your computer and use it in GitHub Desktop.
Save sudar/7e7d8988201775d53103bffb34dad039 to your computer and use it in GitHub Desktop.
How to find if you are on the last page of a multi-page post in WordPress. Explanation at http://sudarmuthu.com/blog/how-to-find-if-you-are-on-the-last-page-of-a-multi-page-post-in-wordpress/
<?php
/**
* Is the current page the last page of the multi-page post.
*
* @return bool True if last page, False otherwise.
*/
function is_last_page() {
global $page, $numpages, $multipage;
if ( $multipage ) {
if ( $page != $numpages ) {
return false;
} else {
return true;
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment