Templates are the files that control how your WordPress site will look on the Web. These files provide information from your WordPress MySQL database and generate the HTML code which they send to the web browser. WordPress allows you to define as few or as many Templates as you like all under one Theme, through its powerful Theme system. You may configure each of these Template files to use under specific situations.
Template files are the building blocks of your WordPress site. They fit to each other as the pieces of a puzzle to generate the web pages on your site. You can use some templates on all the web pages, while others only under specific conditions.
A usual web page consists of two files:
- the XHTML page to hold the structure and content of the page and
- the CSS Style Sheet which holds the presentation styles of the page.
In WordPress, the (X)HTML structure and the CSS style sheet are present but the content is generated “behind the scenes” by various template files. The template files and the style sheet are stored together as a WordPress Theme.
To generate basic template files within a WordPress Theme, start with an index.php template file in your Theme’s directory.
This file has two main functions:
- Include or “call” the other template files
- Include the WordPress Loop to gather information from the database (posts, pages, categories, etc.)
For simple structure, you only need to include two other template files: the header and the footer. These must be named header.php and footer.php.
The Template Tags that include them look like this:
<?php get_header(); ?>
<?php get_footer(); ?>
Hope this was helpful, guys!