# get_next_comments_link()

URL: https://chugunov.pro/api-wordpress/functions/get_next_comments_link/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 2.7.1.

## Сигнатура

```php
get_next_comments_link( string $label = '', int $max_page, int|null $page = null ): string|null
```

## Описание

Получает ссылку на следующую страницу комментариев.

## Параметры

- `$label` `string` — необязательный, по умолчанию `''`. Текст ссылки.
- `$max_page` `int` — необязательный. Максимальный номер страницы. Значение по умолчанию 0.
- `$page` `int|null` — необязательный, по умолчанию `null`. Номер страницы.

## Возвращаемое значение

`string|null`

## Исходный код

Файл: `wp-includes/link-template.php:3129`

```php
function get_next_comments_link( $label = '', $max_page = 0, $page = null ) {
	global $wp_query;

	if ( ! is_singular() ) {
		return null;
	}

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

	if ( ! $page ) {
		$page = 1;
	}

	$next_page = (int) $page + 1;

	if ( empty( $max_page ) ) {
		$max_page = $wp_query->max_num_comment_pages;
	}

	if ( empty( $max_page ) ) {
		$max_page = get_comment_pages_count();
	}

	if ( $next_page > $max_page ) {
		return null;
	}

	if ( empty( $label ) ) {
		$label = __( 'Newer Comments &raquo;' );
	}

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

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

## История изменений

- 6.7.0 — Added the page parameter.
- 2.7.1 — Introduced.

## Связанные

Использует: [`is_singular`](https://chugunov.pro/api-wordpress/functions/is_singular/), [`get_query_var`](https://chugunov.pro/api-wordpress/functions/get_query_var/), `WP_Query`, [`get_comments_pagenum_link`](https://chugunov.pro/api-wordpress/functions/get_comments_pagenum_link/), [`get_comment_pages_count`](https://chugunov.pro/api-wordpress/functions/get_comment_pages_count/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`esc_url`](https://chugunov.pro/api-wordpress/functions/esc_url/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: [`get_the_comments_navigation`](https://chugunov.pro/api-wordpress/functions/get_the_comments_navigation/), [`next_comments_link`](https://chugunov.pro/api-wordpress/functions/next_comments_link/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/get_next_comments_link/
