get_previous_comments_link

Retrieves the link to the previous comments page.

Description

(string|void) get_previous_comments_link( (string) $label = '' ); 

Returns (string|void)

HTML-formatted link for the previous page of comments.

Parameters (1)

0. $label — Optional. (string) => ''
Label for comments link text. Default empty.

Usage

  1. if ( !function_exists( 'get_previous_comments_link' ) ) { 
  2. require_once ABSPATH . WPINC . '/link-template.php'; 
  3.  
  4. // Optional. Label for comments link text. Default empty. 
  5. $label = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_previous_comments_link($label); 
  9.  

Defined (1)

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

/wp-includes/link-template.php  
  1. function get_previous_comments_link( $label = '' ) { 
  2. if ( ! is_singular() ) 
  3. return; 
  4.  
  5. $page = get_query_var('cpage'); 
  6.  
  7. if ( intval($page) <= 1 ) 
  8. return; 
  9.  
  10. $prevpage = intval($page) - 1; 
  11.  
  12. if ( empty($label) ) 
  13. $label = __('« Older Comments'); 
  14.  
  15. /** 
  16. * Filters the anchor tag attributes for the previous comments page link. 
  17. * @since 2.7.0 
  18. * @param string $attributes Attributes for the anchor tag. 
  19. */ 
  20. return '<a href="' . esc_url( get_comments_pagenum_link( $prevpage ) ) . '" ' . apply_filters( 'previous_comments_link_attributes', '' ) . '>' . preg_replace('/&([^#])(?![a-z]{1, 8};)/i', '&$1', $label) .'</a>';