Languages: English • 日本語 (Add your language)
Returns a paginated navigation composed of page numbers linked to the next/previous set of posts if they exist. These functions are used for post listings (like index.php) or archives (like archives.php).
This function only returns the markup. To display it you must echo it or use the_posts_pagination().
If the post is not paginated it returns an empty string.
<?php $pagination = get_the_posts_pagination(); ?>
The following example returns the pagination with two page links before the current page and two page links after the current page.
<?php
$pagination = get_the_posts_pagination( array(
'mid_size' => 2,
) );
?>
The following snippet returns the pagination replacing Next with Older and Previous with Newer.
<?php
$pagination = get_the_posts_pagination( array(
'mid_size' => 2,
'prev_text' => __( 'Newer', 'textdomain' ),
'next_text' => __( 'Older', 'textdomain' ),
) );
?>
wp-includes/link-template.php