Functions
Next Page: next_page_ID($id)
Previous Page: previous_page_ID($id)
$id
: The ID of the page you're trying to get the next or previous page for.
Examples
$next_ID = next_page_ID('41);
$previous_ID = previous_page_ID('41);
$next_url = get_permalink($next_ID);
echo '<a href="' . $next_url . '">Next Page</a>';
Thanks for this. This is a modified version that shows the next parent page when the last child is reached.