Using WordPress ‘next_comments_link()’ PHP function

The next_comments_link() WordPress PHP function displays a link to the next comments page.

Usage

next_comments_link( $label, $max_page );

Custom example:

Input:

next_comments_link( 'View more comments', 3 );

Output:

<a href="yourwebsite.com/post-slug/comment-page-2/#comments">View more comments</a>

Parameters

  • $label (string) Optional: Label for link text. Default: ”
  • $max_page (int) Optional: Max page. Default: 0

More information

See WordPress Developer Resources: next_comments_link()

Examples

Basic usage

Display the link to the next comments page with default settings.

next_comments_link();

Custom label

Display the link to the next comments page with a custom label.

next_comments_link( 'Next comments page' );

Limiting the maximum number of pages

Display the link to the next comments page, limiting the maximum number of pages to 5.

next_comments_link( 'Next comments page', 5 );

Custom label and max pages

Display the link to the next comments page with a custom label and limiting the maximum number of pages to 3.

next_comments_link( 'Load more comments', 3 );

Using translation function

Display the link to the next comments page with a translated custom label.

next_comments_link( __( 'Suivant', 'your-textdomain' ) );