WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/the posts pagination

Description

The posts pagination function outputs a set of page numbers with links to the previous and next pages of posts. These functions are used for post listings (like index.php) or archives (like archives.php).

This function echoes the return of get_the_posts_pagination().

Usage

 <?php the_posts_pagination$args ); ?> 

Parameters

$args
(array) (optional) Array of optional arguments.
Default: None
  • mid_size (int) - How many page numbers to display to either side of the current page. Defaults to 1.
  • prev_text (string) - Text of the link to the next set of posts. Defaults to “Previous”.
  • next_text (string) - Text of the link to the next set of posts. Defaults to “Next”.
  • screen_reader_text (string) - Text meant for screen readers. Defaults to “Posts navigation”.

Examples

Displays Pagination with Additional Page Links


<?php the_posts_pagination( array( 'mid_size' => ) ); ?>

Displays Pagination with Alternative Prev/Next Text


<?php the_posts_pagination( array(
    
'mid_size' => 2,
    
'prev_text' => __'Back''textdomain' ),
    
'next_text' => __'Onward''textdomain' ),
) ); 
?>

Change Log

Related