Difference between revisions of "WordPress Template"
Karl Jones (Talk | contribs) (→See also) |
Karl Jones (Talk | contribs) (→category.php) |
||
Line 31: | Line 31: | ||
=== category.php === | === category.php === | ||
− | The <code> | + | The <code>category.php</code> Template displays [[WordPress Post|WordPress Posts]] in a specific [[WordPress Category]]. |
=== Header and Footer Templates === | === Header and Footer Templates === |
Revision as of 16:29, 13 October 2016
In WordPress, a Template is a PHP document which controls how WordPress content is displayed.
Templates are part of WordPress Themes.
Contents
How Templates work
Template files get data from your WordPress MySQL database, and use the data to generate the HTML, CSS, and JavaScript which is sent to a web page.
Template file names
Templates have specific file names, and each file has a specific purpose.
index.php
All Themes must include a Template file named index.php
. This is the fundamental Template for any Theme.
No other Templates are required for a valid Theme, but most Themes use other Template files as well, which override index.php
for different types of information.
Some of the commonly used Template files are listed below.
single.php
The single.php
Template displays a single WordPress Post.
See also WordPress Permalink -- the URL for displaying a single WordPress Post.
page.php
The page.php
Template displays a single WordPress Page.
category.php
The category.php
Template displays WordPress Posts in a specific WordPress Category.
Most WordPress Themes use files named header.php
and footer.php
, which are included in index.php
and other Templates.
This makes for consistent style and behavior across multiple Templates within a Theme.
header.php
contains the top part of a web page:
- The Document type declaration
- The opening tag of the body element
- The head element
- The opening tag of the body element
- The top visible portion of the web page, such as logo, site name, and primary navigation links
footer.php
contains the bottom part of a web page:
- The lower visible portion of the web page, typically containing copyright and other supporting information
- The closing tag of the body element
- The closing tag of the body element
Template hierarchy
All themes must include the Template file named index.php
.
Additional WordPress Templates form a hierarchy, with rules about which Template applies in a given situation.
Some Templates override other Templates. This varies according to which Templates you use, and how you use them. Commonly used Template files include:
See WordPress Template hierarchy
See also
External links
- Templates @ codex.wordpress.org
- Template Files @ developer.wordpress.org
- Stepping Into Templates @ codex.wordpress.org