Example 1 — Default link
Print the link to the previous page.
<div class="nav-previous"><?php previous_comments_link(); ?></div> How It Works
- The visitor is on comment page 2.
- WordPress builds a link to page 1.
- The link ends with #comments.

In WordPress, previous_comments_link() prints a link to the previous page of comments. The default text is « Older Comments.
It works only when you turn on Break comments into pages in Settings → Discussion. Use it together with next_comments_link().
Call it with no text for the default label, or set your own label.
previous_comments_link();
previous_comments_link( '« Older comments' ); | Call | What it does |
|---|---|
previous_comments_link() | Prints the link with the default text. |
previous_comments_link( '« Older' ) | Prints the link with your own text. |
get_previous_comments_link() | Returns the link instead of printing it. |
Nothing is printed on the first page of comments.
previous_comments_link( string $label = '' ): void | Parameter | Description |
|---|---|
$label | Optional. The text of the link. Default « Older Comments. |
| Return Value | Description |
|---|---|
| void | Nothing is returned. The function prints one link, or nothing on the first page. |
Three short theme examples. Each one has a sample output.
Print the link to the previous page.
<div class="nav-previous"><?php previous_comments_link(); ?></div> Use your own text.
<?php previous_comments_link( 'Show older comments' ); ?> See what happens on the first page of comments.
<div class="nav-previous"><?php previous_comments_link(); ?></div> Print the whole list of comments for a post, with nesting and avatars.
12 people found this page helpful