# get_the_post_navigation()

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

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

## Сигнатура

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

## Описание

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

## Параметры

- `$args` `array` — необязательный, по умолчанию `array()`. Аргументы навигации по записям по умолчанию.
  
  prev_text stringТекст ссылки на предыдущую запись.
  
  Значение по умолчанию '%title'.
  
  next_text stringТекст ссылки на следующую запись.
  
  Значение по умолчанию '%title'.
  
  in_same_term boolДолжна ли ссылка вести в пределах того же термина таксономии.
  
  Значение по умолчанию false.
  
  excluded_terms int[]|stringМассив или список идентификаторов исключаемых терминов через запятую.
  
  taxonomy stringТаксономия, если $in_same_term равно true. Значение по умолчанию 'category'.
  
  screen_reader_text stringТекст для программ чтения с экрана для элемента nav.
  
  Значение по умолчанию ‘Post navigation’.
  
  aria_label stringТекст ARIA-метки для элемента nav. Значение по умолчанию 'Posts'.
  
  class stringПользовательский класс для элемента nav. Значение по умолчанию 'post-navigation'.

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

`string`

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

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

```php
function get_the_post_navigation( $args = array() ) {
	// 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'          => '%title',
			'next_text'          => '%title',
			'in_same_term'       => false,
			'excluded_terms'     => '',
			'taxonomy'           => 'category',
			'screen_reader_text' => __( 'Post navigation' ),
			'aria_label'         => __( 'Posts' ),
			'class'              => 'post-navigation',
		)
	);

	$navigation = '';

	$previous = get_previous_post_link(
		'<div class="nav-previous">%link</div>',
		$args['prev_text'],
		$args['in_same_term'],
		$args['excluded_terms'],
		$args['taxonomy']
	);

	$next = get_next_post_link(
		'<div class="nav-next">%link</div>',
		$args['next_text'],
		$args['in_same_term'],
		$args['excluded_terms'],
		$args['taxonomy']
	);

	// Only add markup if there's somewhere to navigate to.
	if ( $previous || $next ) {
		$navigation = _navigation_markup( $previous . $next, $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 the in_same_term, excluded_terms, and taxonomy arguments.
- 4.1.0 — Introduced.

## Связанные

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

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