# get_the_comments_navigation()

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

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

## Сигнатура

```php
get_the_comments_navigation( array $args = array() ): string
```

## Описание

Получает навигацию к следующему/предыдущему набору комментариев, когда это применимо.

## Параметры

- `$args` `array` — необязательный, по умолчанию `array()`. Аргументы навигации по комментариям по умолчанию.
  
  prev_text stringТекст ссылки для перехода к предыдущим комментариям.
  
  Значение по умолчанию ‘Older comments’.
  
  next_text stringТекст ссылки для перехода к следующим комментариям.
  
  Значение по умолчанию ‘Newer comments’.
  
  screen_reader_text stringТекст для программ чтения с экрана для элемента nav. Значение по умолчанию ‘Comments navigation’.
  
  aria_label stringТекст ARIA-метки для элемента nav. Значение по умолчанию 'Comments'.
  
  class stringПроизвольный класс для элемента nav. Значение по умолчанию 'comment-navigation'.

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

`string`

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

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

```php
function get_the_comments_navigation( $args = array() ) {
	$navigation = '';

	// Are there comments to navigate through?
	if ( get_comment_pages_count() > 1 ) {
		// Make sure the nav element has an aria-label attribute: fallback to the screen reader text.
		if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) {
			$args['aria_label'] = $args['screen_reader_text'];
		}

		$args = wp_parse_args(
			$args,
			array(
				'prev_text'          => __( 'Older comments' ),
				'next_text'          => __( 'Newer comments' ),
				'screen_reader_text' => __( 'Comments navigation' ),
				'aria_label'         => __( 'Comments' ),
				'class'              => 'comment-navigation',
			)
		);

		$prev_link = get_previous_comments_link( $args['prev_text'] );
		$next_link = get_next_comments_link( $args['next_text'] );

		if ( $prev_link ) {
			$navigation .= '<div class="nav-previous">' . $prev_link . '</div>';
		}

		if ( $next_link ) {
			$navigation .= '<div class="nav-next">' . $next_link . '</div>';
		}

		$navigation = _navigation_markup( $navigation, $args['class'], $args['screen_reader_text'], $args['aria_label'] );
	}

	return $navigation;
}
```

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

- 5.5.0 — Added the class parameter.
- 5.3.0 — Added the aria_label parameter.
- 4.4.0 — Introduced.

## Связанные

Использует: [`_navigation_markup`](https://chugunov.pro/api-wordpress/functions/_navigation_markup/), [`get_previous_comments_link`](https://chugunov.pro/api-wordpress/functions/get_previous_comments_link/), [`get_next_comments_link`](https://chugunov.pro/api-wordpress/functions/get_next_comments_link/), [`get_comment_pages_count`](https://chugunov.pro/api-wordpress/functions/get_comment_pages_count/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`wp_parse_args`](https://chugunov.pro/api-wordpress/functions/wp_parse_args/).
Используется в: [`the_comments_navigation`](https://chugunov.pro/api-wordpress/functions/the_comments_navigation/).

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