Using WordPress ‘get_next_comments_link()’ PHP function

The get_next_comments_link() WordPress PHP function retrieves the link to the next comments page.

Usage

get_next_comments_link( $label, $max_page );

Example:

echo get_next_comments_link( 'Next Comments', 3 );

This will output a link to the next comments page with the text “Next Comments” and a maximum of 3 pages.

Parameters

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

More information

See WordPress Developer Resources: get_next_comments_link

Examples

This code will display the next comments link with default label and no maximum page limit.

echo get_next_comments_link();

This code will display the next comments link with custom link text “View More Comments”.

echo get_next_comments_link( 'View More Comments' );

Custom max pages

This code will display the next comments link with a maximum of 5 pages.

echo get_next_comments_link( '', 5 );

This code will display the next comments link with custom link text “See More Comments” and a maximum of 4 pages.

echo get_next_comments_link( 'See More Comments', 4 );

This code will display the next comments link only if there are more comments pages.

if ( get_next_comments_link() ) {
    echo get_next_comments_link( 'Load More Comments', 2 );
}