Template files are the building blocks of your WordPress site. They fit together like the pieces of a puzzle to generate the web pages on your site. Some templates (the header and footer template files for example) are used on all the web pages, while others are used only under specific conditions.
A traditional web page consists of two files:
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 learn more about creating Themes, read Theme Development.
A simple WordPress web page structure is made up of three basic building “blocks”: a header, the content, and a footer. Each of these blocks is generated by a template file in your current WordPress Theme.
To generate such a structure within a WordPress Theme, start with an index.php template file in your Theme’s directory. This file has two main functions:
For our simple structure, we 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(); ?>
In order to display the posts and pages of your blog (and to customize how they are being displayed), your index.php file should run the WordPress Loop between the header and footer calls.