# get_page_template()

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

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

## Сигнатура

```php
get_page_template(): string
```

## Описание

Note: For block themes, use [locate_block_template()](https://developer.wordpress.org/reference/functions/locate_block_template/) function instead.

The hierarchy for this template looks like:

- {Page Template}.php

- page-{page_name}.php

- page-{id}.php

- page.php
An example of this is:

- page-templates/full-width.php

- page-about.php

- page-4.php

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

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

`string`

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

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

```php
function get_page_template() {
	$id       = get_queried_object_id();
	$template = get_page_template_slug();
	$pagename = get_query_var( 'pagename' );

	if ( ! $pagename && $id ) {
		/*
		 * If a static page is set as the front page, $pagename will not be set.
		 * Retrieve it from the queried object.
		 */
		$post = get_queried_object();
		if ( $post ) {
			$pagename = $post->post_name;
		}
	}

	$templates = array();
	if ( $template && 0 === validate_file( $template ) ) {
		$templates[] = $template;
	}
	if ( $pagename ) {
		$pagename_decoded = urldecode( $pagename );
		if ( $pagename_decoded !== $pagename ) {
			$templates[] = "page-{$pagename_decoded}.php";
		}
		$templates[] = "page-{$pagename}.php";
	}
	if ( $id ) {
		$templates[] = "page-{$id}.php";
	}
	$templates[] = 'page.php';

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

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

- 4.7.0 — The decoded form of page-{page_name}.php was added to the top of the template hierarchy when the page name contains multibyte characters.
- 1.5.0 — Introduced.

## Связанные

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