next_posts

Displays or retrieves the next posts page link.

Description

(string|void) next_posts( (int) $max_page = 0, (bool) $echo = true ); 

Returns (string|void)

The link URL for next posts page if `$echo = false`.

Parameters (2)

0. $max_page — Optional. (int)
Max pages. Default 0.
1. $echo — Optional. (bool) => true
Whether to echo the link. Default true.

Usage

  1. if ( !function_exists( 'next_posts' ) ) { 
  2. require_once ABSPATH . WPINC . '/link-template.php'; 
  3.  
  4. // Optional. Max pages. Default 0. 
  5. $max_page = -1; 
  6.  
  7. // Optional. Whether to echo the link. Default true. 
  8. $echo = true; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = next_posts($max_page, $echo); 
  12.  

Defined (1)

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

/wp-includes/link-template.php  
  1. function next_posts( $max_page = 0, $echo = true ) { 
  2. $output = esc_url( get_next_posts_page_link( $max_page ) ); 
  3.  
  4. if ( $echo ) 
  5. echo $output; 
  6. else 
  7. return $output;