# the_shortlink()

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

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

## Сигнатура

```php
the_shortlink( string $text = '', string $title = '', string $before = '', string $after = '' )
```

## Описание

Должна вызываться внутри «Цикла» (The Loop).
Вызывайте так: the_shortlink( __( ‘Shortlinkage FTW’ ) )

## Параметры

- `$text` `string` — необязательный, по умолчанию `''`. Текст ссылки или HTML для отображения. По умолчанию «This is the short link.»
- `$title` `string` — необязательный, по умолчанию `''`. Не используется.
- `$before` `string` — необязательный, по умолчанию `''`. HTML для отображения перед ссылкой.
- `$after` `string` — необязательный, по умолчанию `''`. HTML для отображения после ссылки.

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

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

```php
function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) {
	$post = get_post();

	if ( empty( $text ) ) {
		$text = __( 'This is the short link.' );
	}

	$shortlink = wp_get_shortlink( $post->ID );

	if ( ! empty( $shortlink ) ) {
		$link = '<a rel="shortlink" href="' . esc_url( $shortlink ) . '">' . $text . '</a>';

		/**
		 * Filters the short link anchor tag for a post.
		 *
		 * @since 3.0.0
		 *
		 * @param string $link      Shortlink anchor tag.
		 * @param string $shortlink Shortlink URL.
		 * @param string $text      Shortlink's text.
		 * @param string $title     Shortlink's title attribute. Unused.
		 */
		$link = apply_filters( 'the_shortlink', $link, $shortlink, $text, $title );
		echo $before, $link, $after;
	}
}
```

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

- 6.8.0 — Removed title attribute.
- 3.0.0 — Introduced.

## Связанные

Использует: [`wp_get_shortlink`](https://chugunov.pro/api-wordpress/functions/wp_get_shortlink/), [`__`](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_post`](https://chugunov.pro/api-wordpress/functions/get_post/).

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