Title: get_previous_comments_link
Published: April 25, 2014
Last modified: August 20, 2026

---

# get_previous_comments_link( string $label = ”, int|null $page = null ): string|null

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/get_previous_comments_link/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_previous_comments_link/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_previous_comments_link/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_previous_comments_link/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_previous_comments_link/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_previous_comments_link/?output_format=md#changelog)

Retrieves the link to the previous comments page.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_previous_comments_link/?output_format=md#parameters)󠁿

 `$label`stringoptional

Label for comments link text.

Default:`''`

`$page`int|nulloptional

Page number.

Default:`null`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_previous_comments_link/?output_format=md#return)󠁿

 string|null HTML-formatted link for the previous page of comments.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_previous_comments_link/?output_format=md#source)󠁿

    ```php
    function get_previous_comments_link( $label = '', $page = null ) {
    	if ( ! is_singular() ) {
    		return null;
    	}

    	if ( is_null( $page ) ) {
    		$page = get_query_var( 'cpage' );
    	}

    	if ( (int) $page <= 1 ) {
    		return null;
    	}

    	$previous_page = (int) $page - 1;

    	if ( empty( $label ) ) {
    		$label = __( '&laquo; Older Comments' );
    	}

    	/**
    	 * Filters the anchor tag attributes for the previous comments page link.
    	 *
    	 * @since 2.7.0
    	 *
    	 * @param string $attributes Attributes for the anchor tag.
    	 */
    	$attr = apply_filters( 'previous_comments_link_attributes', '' );

    	return sprintf(
    		'<a href="%1$s" %2$s>%3$s</a>',
    		esc_url( get_comments_pagenum_link( $previous_page ) ),
    		$attr,
    		preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label )
    	);
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/link-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/link-template.php#L3201)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/link-template.php#L3201-L3235)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_previous_comments_link/?output_format=md#hooks)󠁿

 [apply_filters( ‘previous_comments_link_attributes’, string $attributes )](https://developer.wordpress.org/reference/hooks/previous_comments_link_attributes/)

Filters the anchor tag attributes for the previous comments page link.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_previous_comments_link/?output_format=md#related)󠁿

| Uses | Description | 
| [is_singular()](https://developer.wordpress.org/reference/functions/is_singular/)`wp-includes/query.php` |

Determines whether the query is for an existing single post of any post type (post, attachment, page, custom post types).

  | 
| [get_query_var()](https://developer.wordpress.org/reference/functions/get_query_var/)`wp-includes/query.php` |

Retrieves the value of a query variable in the [WP_Query](https://developer.wordpress.org/reference/classes/wp_query/) class.

  | 
| [get_comments_pagenum_link()](https://developer.wordpress.org/reference/functions/get_comments_pagenum_link/)`wp-includes/link-template.php` |

Retrieves the comments page number link.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [esc_url()](https://developer.wordpress.org/reference/functions/esc_url/)`wp-includes/formatting.php` |

Checks and cleans a URL.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 3 more](https://developer.wordpress.org/reference/functions/get_previous_comments_link/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_previous_comments_link/?output_format=md#)

| Used by | Description | 
| [get_the_comments_navigation()](https://developer.wordpress.org/reference/functions/get_the_comments_navigation/)`wp-includes/link-template.php` |

Retrieves navigation to next/previous set of comments, when applicable.

  | 
| [previous_comments_link()](https://developer.wordpress.org/reference/functions/previous_comments_link/)`wp-includes/link-template.php` |

Displays the link to the previous comments page.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_previous_comments_link/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.7.0](https://developer.wordpress.org/reference/since/6.7.0/) | Added the `page` parameter. | 
| [2.7.1](https://developer.wordpress.org/reference/since/2.7.1/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_previous_comments_link%2F)
before being able to contribute a note or feedback.