get_previous_posts_link

Retrieves the previous posts page link.

Description

(string|void) get_previous_posts_link( (null) $label = null ); 

Returns (string|void)

HTML-formatted previous page link.

Parameters (1)

0. $label — Optional. (null) => null
Previous page link text.

Usage

  1. if ( !function_exists( 'get_previous_posts_link' ) ) { 
  2. require_once ABSPATH . WPINC . '/link-template.php'; 
  3.  
  4. // Optional. Previous page link text. 
  5. $label = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_previous_posts_link($label); 
  9.  

Defined (1)

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

/wp-includes/link-template.php  
  1. function get_previous_posts_link( $label = null ) { 
  2. global $paged; 
  3.  
  4. if ( null === $label ) 
  5. $label = __( '« Previous Page' ); 
  6.  
  7. if ( !is_single() && $paged > 1 ) { 
  8. /** 
  9. * Filters the anchor tag attributes for the previous posts page link. 
  10. * @since 2.7.0 
  11. * @param string $attributes Attributes for the anchor tag. 
  12. */ 
  13. return '<a href="' . previous_posts( false ) . "\" $attr>". preg_replace( '/&([^#])(?![a-z]{1, 8};)/i', '&$1', $label ) .'</a>';