# wp_link_pages()

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

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

## Сигнатура

```php
wp_link_pages( string|array $args = '' ): string
```

## Описание

Выводит ссылки на страницы для записей, разбитых на страницы (то есть содержащих Quicktag один или несколько раз). Этот тег должен использоваться внутри цикла (The Loop).

## Параметры

- `$args` `string|array` — необязательный, по умолчанию `''`. Массив или строка аргументов по умолчанию.
  
  before stringHTML или текст, добавляемый перед каждой ссылкой. По умолчанию — Pages:.
  
  after stringHTML или текст, добавляемый после каждой ссылки. По умолчанию — .
  
  link_before stringHTML или текст, добавляемый перед каждой ссылкой, внутри тега .
  
  Также добавляется перед текущим элементом, который не является ссылкой.
  
  link_after stringHTML или текст, добавляемый после каждой ссылки Pages внутри тега .
  
  Также добавляется после текущего элемента, который не является ссылкой.
  
  aria_current stringЗначение атрибута aria-current. Возможные значения: 'page', 'step', 'location', 'date', 'time', 'true', 'false'. По умолчанию — 'page'.
  
  next_or_number stringУказывает, следует ли использовать номера страниц. Допустимые значения — number и next. По умолчанию — 'number'.
  
  separator stringТекст между ссылками пагинации. По умолчанию — ' '.
  
  nextpagelink stringТекст ссылки на следующую страницу, если она доступна. По умолчанию — 'Next Page'.
  
  previouspagelink stringТекст ссылки на предыдущую страницу, если она доступна. По умолчанию — 'Previous Page'.
  
  pagelink stringСтрока формата для номеров страниц. Символ % в строке параметра будет заменён номером страницы, так что 'Page %' формирует "Page 1", "Page 2" и т. д.
  
  По умолчанию — '%', только номер страницы.
  
  echo int|boolВыводить или нет. Принимает 1|true или 0|false. По умолчанию 1|true.

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

`string`

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

Файл: `wp-includes/post-template.php:958`

```php
function wp_link_pages( $args = '' ) {
	global $page, $numpages, $multipage, $more;

	$defaults = array(
		'before'           => '<p class="post-nav-links">' . __( 'Pages:' ),
		'after'            => '</p>',
		'link_before'      => '',
		'link_after'       => '',
		'aria_current'     => 'page',
		'next_or_number'   => 'number',
		'separator'        => ' ',
		'nextpagelink'     => __( 'Next page' ),
		'previouspagelink' => __( 'Previous page' ),
		'pagelink'         => '%',
		'echo'             => 1,
	);

	$parsed_args = wp_parse_args( $args, $defaults );

	/**
	 * Filters the arguments used in retrieving page links for paginated posts.
	 *
	 * @since 3.0.0
	 *
	 * @param array $parsed_args An array of page link arguments. See wp_link_pages()
	 *                           for information on accepted arguments.
	 */
	$parsed_args = apply_filters( 'wp_link_pages_args', $parsed_args );

	$output = '';
	if ( $multipage ) {
		if ( 'number' === $parsed_args['next_or_number'] ) {
			$output .= $parsed_args['before'];
			for ( $i = 1; $i <= $numpages; $i++ ) {
				$link = $parsed_args['link_before'] . str_replace( '%', $i, $parsed_args['pagelink'] ) . $parsed_args['link_after'];

				if ( $i !== $page || ! $more && 1 === $page ) {
					$link = _wp_link_page( $i ) . $link . '</a>';
				} elseif ( $i === $page ) {
					$link = '<span class="post-page-numbers current" aria-current="' . esc_attr( $parsed_args['aria_current'] ) . '">' . $link . '</span>';
				}

				/**
				 * Filters the HTML output of individual page number links.
				 *
				 * @since 3.6.0
				 *
				 * @param string $link The page number HTML output.
				 * @param int    $i    Page number for paginated posts' page links.
				 */
				$link = apply_filters( 'wp_link_pages_link', $link, $i );

				// Use the custom links separator beginning with the second link.
				$output .= ( 1 === $i ) ? ' ' : $parsed_args['separator'];
				$output .= $link;
			}
			$output .= $parsed_args['after'];
		} elseif ( $more ) {
			$output .= $parsed_args['before'];
			$prev    = $page - 1;
			if ( $prev > 0 ) {
				$link = _wp_link_page( $prev ) . $parsed_args['link_before'] . $parsed_args['previouspagelink'] . $parsed_args['link_after'] . '</a>';

				/** This filter is documented in wp-includes/post-template.php */
				$output .= apply_filters( 'wp_link_pages_link', $link, $prev );
			}
			$next = $page + 1;
			if ( $next <= $numpages ) {
				if ( $prev ) {
					$output .= $parsed_args['separator'];
				}
				$link = _wp_link_page( $next ) . $parsed_args['link_before'] . $parsed_args['nextpagelink'] . $parsed_args['link_after'] . '</a>';

				/** This filter is documented in wp-includes/post-template.php */
				$output .= apply_filters( 'wp_link_pages_link', $link, $next );
			}
			$output .= $parsed_args['after'];
		}
	}

	/**
	 * Filters the HTML output of page links for paginated posts.
	 *
	 * @since 3.6.0
	 *
	 * @param string       $output HTML output of paginated posts' page links.
	 * @param array|string $args   An array or query string of arguments. See wp_link_pages()
	 *                             for information on accepted arguments.
	 */
	$html = apply_filters( 'wp_link_pages', $output, $args );

	if ( $parsed_args['echo'] ) {
		echo $html;
	}
	return $html;
}
```

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

- 5.1.0 — Added the aria_current argument.
- 1.2.0 — Introduced.

## Связанные

Использует: [`_wp_link_page`](https://chugunov.pro/api-wordpress/functions/_wp_link_page/), [`wp_link_pages`](https://chugunov.pro/api-wordpress/functions/wp_link_pages/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`esc_attr`](https://chugunov.pro/api-wordpress/functions/esc_attr/), [`wp_parse_args`](https://chugunov.pro/api-wordpress/functions/wp_parse_args/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: [`link_pages`](https://chugunov.pro/api-wordpress/functions/link_pages/).

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