- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
関数リファレンス/get page template
提供: WordPress Codex 日本語版
< 関数リファレンス
2018年6月1日 (金) 22:27時点におけるGblsm (トーク | 投稿記録)による版 (en:Function_Reference/get_page_template 22:59, 2 February 2014 Olarmarius 版を流し込み、Code Reference 最新版をマージ。)
このページ「関数リファレンス/get page template」は未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています。
目次
Description
Retrieve path of page template in current or parent template.
First attempt is to look for the file in the '_wp_page_template' page meta data. The second attempt, if the first has a file and is not empty, is to look for 'page.php'.
Usage
<?php get_page_template(); ?>
Parameters
None.
Return Values
- (string)
- Returns path of page template in current or parent template.
Examples
Displays the filename of the page template used to render a Page (printed within an HTML comment, in this example) :
<?php echo '<!-- ' . basename( get_page_template() ) . ' -->'; ?>
Notes
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' and '$type_template' dynamic hooks, where $type is 'page'.
Change Log
Since: 1.5.0
Source File
get_page_template() is located in wp-includes/template.php
.
Related
関数リファレンス、テンプレートタグ目次もご覧ください。