トップページ(ホームページ)表示
優先順位 | テンプレートファイル名 |
---|
1 | front-page.php |
3 | home.php |
4 | index.php |
個別投稿表示
優先順位 | テンプレートファイル名 |
---|
1 | single-[post_type].php |
2 | single.php |
3 | singular.php |
4 | index.php |
固定ページ表示
優先順位 | テンプレートファイル名 |
---|
1 | カスタムテンプレート名.php |
2 | page-[slug].php |
3 | page-[ID].php |
4 | page.php |
5 | singular.php |
6 | index.php |
カテゴリー表示
優先順位 | テンプレートファイル名 |
---|
1 | category-[slug].php |
2 | category-[ID].php |
3 | category.php |
4 | archive.php |
5 | index.php |
タグ表示
優先順位 | テンプレートファイル名 |
---|
1 | tag-[slug].php |
2 | tag-[ID].php |
3 | tag.php |
4 | archive.php |
5 | index.php |
カスタムタクソノミー表示
優先順位 | テンプレートファイル名 |
---|
1 | taxonomy-[taxonomy]-[teram].php |
2 | taxsonomy-[taxsonomy].php |
3 | taxsonomy.php |
4 | archive.php |
5 | index.php |
カスタム投稿タイプ表示
優先順位 | テンプレートファイル名 |
---|
1 | archive-[post_type].php |
2 | archive.php |
3 | index.php |
作成者表示
優先順位 | テンプレートファイル名 |
---|
1 | author-[name].php |
2 | author-[ID].php |
3 | author.php |
4 | archive.php |
5 | index.php |
日付別表示
優先順位 | テンプレートファイル名 |
---|
1 | date.php |
2 | archive.php |
3 | index.php |
検索結果表示
優先順位 | テンプレートファイル名 |
---|
1 | search.php |
2 | index.php |
404エラー表示
優先順位 | テンプレートファイル名 |
---|
1 | 404.php |
2 | index.php |
添付ファイル表示
優先順位 | テンプレートファイル名 |
---|
1 | MIME_TYPE.php |
2 | attachment.php |
3 | single.php |
4 | index.php |
テンプレート階層とは?
「テンプレート階層」とは、WordPressが定めたテンプレートファイルを出力する際の仕組み・ルールのことです。
ページごとに、どのテンプレートファイルを呼び出すか優先順位が決まっています。
優先順位
- アクセスされたURLからページの種類を判別
- ページの種類ごと(TOPページ?固定ページ?)にテンプレート階層上位のテンプレートファイルから探す
- 最初に一致するテンプレートファイルがある場合、そのテンプレートファイルを使用
- 一致しなければ階層内の次のファイルを探す
- どれにも一致しない場合「index.php」を使用する
WordPressの定めたルール、優先順位に従ってテンプレートファイルをカスタマイズしていきましょう!