# get_single_template()

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

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

## Сигнатура

```php
get_single_template(): string
```

## Описание

The hierarchy for this template looks like:

- {Post Type Template}.php

- single-{post_type}-{post_name}.php

- single-{post_type}.php

- single.php
An example of this is:

- templates/full-width.php

- single-post-hello-world.php

- single-post.php

- single.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 ‘single’.[See also](#see-also)
- [get_query_template()](https://developer.wordpress.org/reference/functions/get_query_template/)

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

`string`

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

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

```php
function get_single_template() {
	$object = get_queried_object();

	$templates = array();

	if ( ! empty( $object->post_type ) ) {
		$template = get_page_template_slug( $object );
		if ( $template && 0 === validate_file( $template ) ) {
			$templates[] = $template;
		}

		$name_decoded = urldecode( $object->post_name );
		if ( $name_decoded !== $object->post_name ) {
			$templates[] = "single-{$object->post_type}-{$name_decoded}.php";
		}

		$templates[] = "single-{$object->post_type}-{$object->post_name}.php";
		$templates[] = "single-{$object->post_type}.php";
	}

	$templates[] = 'single.php';

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

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

- 4.7.0 — {Post Type Template}.php was added to the top of the template hierarchy.
- 4.4.0 — single-{post_type}-{post_name}.php was added to the top of the template hierarchy.
- 1.5.0 — Introduced.

## Связанные

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

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