WordPress Version: 6.4
/**
* Displays or retrieves the next posts page link.
*
* @since 0.71
*
* @param int $max_page Optional. Max pages. Default 0.
* @param bool $display Optional. Whether to echo the link. Default true.
* @return string|void The link URL for next posts page if `$display = false`.
*/
function next_posts($max_page = 0, $display = true)
{
$link = get_next_posts_page_link($max_page);
$output = $link ? esc_url($link) : '';
if ($display) {
echo $output;
} else {
return $output;
}
}