# get_tag_template()

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

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

## Сигнатура

```php
get_tag_template(): string
```

## Описание

The hierarchy for this template looks like:

- tag-{slug}.php

- tag-{id}.php

- tag.php
An example of this is:

- tag-wordpress.php

- tag-3.php

- tag.php
The template hierarchy and template path are filterable via the [‘$type_template_hierarchy’](https://developer.wordpress.org/reference/hooks/type_template_hierarchy/) and [‘$type_template’](https://developer.wordpress.org/reference/hooks/type_template/) dynamic hooks, where `$type` is ‘tag’.[See also](#see-also)
- [get_query_template()](https://developer.wordpress.org/reference/functions/get_query_template/)

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

`string`

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

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

```php
function get_tag_template() {
	$tag = get_queried_object();

	$templates = array();

	if ( ! empty( $tag->slug ) ) {

		$slug_decoded = urldecode( $tag->slug );
		if ( $slug_decoded !== $tag->slug ) {
			$templates[] = "tag-{$slug_decoded}.php";
		}

		$templates[] = "tag-{$tag->slug}.php";
		$templates[] = "tag-{$tag->term_id}.php";
	}
	$templates[] = 'tag.php';

	return get_query_template( 'tag', $templates );
}
```

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

- 4.7.0 — The decoded form of tag-{slug}.php was added to the top of the template hierarchy when the tag slug contains multibyte characters.
- 2.3.0 — Introduced.

## Связанные

Использует: [`get_queried_object`](https://chugunov.pro/api-wordpress/functions/get_queried_object/), [`get_query_template`](https://chugunov.pro/api-wordpress/functions/get_query_template/).

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