get_page_template()
Retrieve path of page template in current or parent template.
Note: For block themes, use 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 {@see '$type_template_hierarchy'} and {@see '$type_template'} dynamic hooks, where $type is 'page'.
Uses: get_query_template()
1 time — 0.0007071 sec (slow) | 50000 times — 1.84 sec (fast)
No Hooks.
Return
String
. Full path to page template file.
Usage
get_page_template();
Examples
#1 Get the template file of the current page
echo get_page_template(); //> /home/public_html/wp-content/themes/theme-name/page.php
Notes
- See: get_query_template()
Changelog
Since 1.5.0 | Introduced. |
Since 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. |