Template Hierarchy
From 워드프레스(WORDPRESS) 한국어 위키
Contents |
Introduction
Templates are what WordPress uses to format your WordPress site. Since the introduction of Themes in WordPress v1.5, Templates have become more and more configurable. You can develop new themes with a great amount of customization. If template files are new to you, see Stepping Into Templates. In order to develop or customize themes, a proper understanding of the way WordPress selects template files for displaying the various pages on your blog is essential.
This document attempts to answer the following question.
What template file will WordPress use when the _______________ (page) is displayed?
Visual Overview
This diagram shows which template-files are called in which hierarchy depending on the url the visitor requests. There are also the Conditional Tags (grey text) for each request/page.
Download ArgoUML-0.22-File (zargo)
The Template Selection Hierarchy
In the sections that follow, the section heading fills in the blank in the question above. WordPress looks in the current theme's directory and uses the first template file it finds from the list under the appropriate section below. Note the parallels between the Template Hierarchy and the Conditional Tags.
For example, if your blog is at http://example.com/wordpress/ and a visitor loads the page http://example.com/wordpress/, WordPress looks for a template file called home.php and uses it to generate the requested page. If home.php is missing, WordPress looks for a file called index.php in the active theme's directory, and uses that template to generate the page.
The Main page
- home.php
- index.php
Single Post page
- single.php
- index.php
PAGE page
This section refers to WordPress Pages, not any generic webpage from your blog. Please see Pages for more detailed information.
- The template selected from the "Page Template" dropdown when editing the Page.
- page.php
- index.php
Category page
You can customize Category Templates. In this example, the category in question has a category identification number (cat id) of 6.
- category-6.php
- category.php
- archive.php
- index.php
Please see Category Templates for more information.
Author page
The Author Templates present information on post authors.
- author.php
- archive.php
- index.php
Date page
For example, a monthly archive page.
- date.php
- archive.php
- index.php
Search Result page
- search.php
- index.php
404 Not Found page
- 404.php
- index.php

