Difference between revisions of "WordPress Template"
Karl Jones (Talk | contribs) (Blanked the page) |
Karl Jones (Talk | contribs) (→See also) |
||
(12 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | In [[WordPress]], a '''Template''' is a [[PHP]] document which controls how [[WordPress content]] is displayed. | ||
+ | Templates are part of [[WordPress Theme|WordPress Themes]]. | ||
+ | |||
+ | == How Templates work == | ||
+ | |||
+ | Template files get data from your [[WordPress database|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 <code>index.php</code>. 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 <code>index.php</code> for different types of information. | ||
+ | |||
+ | Some of the commonly used Template files are listed below. | ||
+ | |||
+ | === single.php === | ||
+ | |||
+ | The <code>single.php</code> Template displays a single [[WordPress Post]]. | ||
+ | |||
+ | See also [[WordPress Permalink]] -- the URL for displaying a single WordPress Post. | ||
+ | |||
+ | === page.php === | ||
+ | |||
+ | The <code>page.php</code> Template displays a single [[WordPress Page]]. | ||
+ | |||
+ | === category.php === | ||
+ | |||
+ | The <code>category.php</code> Template displays [[WordPress Post|WordPress Posts]] in a specific [[WordPress Category]]. | ||
+ | |||
+ | === Header and Footer Templates === | ||
+ | |||
+ | Most WordPress Themes use files named <code>header.php</code> and <code>footer.php</code>, which are included in <code>index.php</code> and other Templates. | ||
+ | |||
+ | This makes for consistent style and behavior across multiple Templates within a Theme. | ||
+ | |||
+ | <code>header.php</code> contains the top part of a web page: | ||
+ | |||
+ | * The [[Document type declaration]] | ||
+ | * The opening tag of the [[html (HTML element)|body element]] | ||
+ | * The [[head (HTML element)|head element]] | ||
+ | * The opening tag of the [[body (HTML element)|body element]] | ||
+ | * The top visible portion of the web page, such as logo, site name, and primary navigation links | ||
+ | |||
+ | <code>footer.php</code> 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 (HTML element)|body element]] | ||
+ | * The closing tag of the [[html (HTML element)|body element]] | ||
+ | |||
+ | == Template hierarchy == | ||
+ | |||
+ | All themes must include the Template file named <code>index.php</code>. | ||
+ | |||
+ | 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 == | ||
+ | |||
+ | * [[WordPress]] | ||
+ | * [[WordPress Category Template]] | ||
+ | * [[WordPress content]] | ||
+ | * [[WordPress Loop]] | ||
+ | * [[WordPress Tag]] | ||
+ | * [[WordPress Template hierarchy]] | ||
+ | * [[WordPress Theme]] | ||
+ | |||
+ | == External links == | ||
+ | |||
+ | * [https://codex.wordpress.org/Templates Templates] @ codex.wordpress.org | ||
+ | * [https://developer.wordpress.org/themes/basics/template-files/ Template Files] @ developer.wordpress.org | ||
+ | * [https://codex.wordpress.org/Stepping_into_Templates Stepping Into Templates] @ codex.wordpress.org | ||
+ | |||
+ | |||
+ | [[Category:WordPress]] |
Latest revision as of 17:00, 25 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
- WordPress
- WordPress Category Template
- WordPress content
- WordPress Loop
- WordPress Tag
- WordPress Template hierarchy
- WordPress Theme
External links
- Templates @ codex.wordpress.org
- Template Files @ developer.wordpress.org
- Stepping Into Templates @ codex.wordpress.org