This should do the trick:
/**
* For posts paginated using <!--nextpage-->, return a particular "page" of content.
* This function uses code from WP's setup_postdata() function.
* @param string $content the content to search for paginated page content.
* @param int $page_number the index of the page to return the content for.
*/
function get_nextpage_content( $content, $page_number ) {
if ( strpos( $content, '<!--nextpage-->' ) ) {
$content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content);
$content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content);
$content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content);
$pages = explode('<!--nextpage-->', $content);
return ( isset ( $pages[$page_number - 1] ) ) ? $pages[$page_number - 1] : false;
} else {
return false;
}
}
Usage:
// Get the second page of content with a paginated post
echo apply_filters( 'the_content', get_nextpage_content( $post->post_content, 2 ) );