WordPress Template

From Wiki @ Karl Jones dot com
Revision as of 18:56, 11 October 2016 by Karl Jones (Talk | contribs)

Jump to: navigation, search

In WordPress, a Template is a PHP document which controls how WordPress content is displayed.

Templates are part of WordPress Themes.

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 single.php Template displays WordPress Posts in a specific WordPress Category.

Header and Footer Templates

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:

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