get_the_posts_pagination

Retrieves a paginated navigation to next/previous set of posts, when applicable.

Description

(string) get_the_posts_pagination( (array) $args = array() ); 

Returns (string)

Markup for pagination links.

Parameters (1)

0. $args — Optional. (array) => array()
Default pagination arguments, see paginate_links().

Options

    ;        


    Usage

    1. if ( !function_exists( 'get_the_posts_pagination' ) ) { 
    2. require_once ABSPATH . WPINC . '/link-template.php'; 
    3.  
    4. // Optional. Default pagination arguments, see paginate_links(). 
    5. $args = array(); 
    6.  
    7. // NOTICE! Understand what this does before running. 
    8. $result = get_the_posts_pagination($args); 
    9.  

    Defined (1)

    The function is defined in the following location(s).

    /wp-includes/link-template.php  
    1. function get_the_posts_pagination( $args = array() ) { 
    2. $navigation = ''; 
    3.  
    4. // Don't print empty markup if there's only one page. 
    5. if ( $GLOBALS[wp_query]->max_num_pages > 1 ) { 
    6. $args = wp_parse_args( $args, array( 
    7. 'mid_size' => 1,  
    8. 'prev_text' => _x( 'Previous', 'previous set of posts' ),  
    9. 'next_text' => _x( 'Next', 'next set of posts' ),  
    10. 'screen_reader_text' => __( 'Posts navigation' ),  
    11. ) ); 
    12.  
    13. // Make sure we get a string back. Plain is the next best thing. 
    14. if ( isset( $args['type'] ) && 'array' == $args['type'] ) { 
    15. $args['type'] = 'plain'; 
    16.  
    17. // Set up paginated links. 
    18. $links = paginate_links( $args ); 
    19.  
    20. if ( $links ) { 
    21. $navigation = _navigation_markup( $links, 'pagination', $args['screen_reader_text'] ); 
    22.  
    23. return $navigation;