What is Template in WordPress?

Template

Templates are the files which control how your WordPress site will be shown on the Web. These files draw information from your WordPress MYSQL database and create the HTML code which is sent to the web browser. WordPress enables you to define as few or as many Templates as you like all under one Theme through its powerful Theme system. Each one of these Template files can be configured for use under specific situations. Every last one of these Template documents can be arranged for use under particular circumstances.

In WordPress theme development a template defines some portion of a web page created by a WordPress theme.

Example: header.php is a default template which is used in most WordPress themes. It defines the header area of web pages which is generated or created by WordPress. The header file will be loaded on every page of your WordPress site allowing changes to be made to a single file, that will apply all over the website.

Most of the WordPress themes have some default templates with code for generating HTML output for precise sections of a website.

1- Main – index.php. For displaying the main page of a website.

2- Header – header.php. It displays the header section.

3- Sidebar – sidebar.php. Generates or creates HTML output for the sidebar section.

4- Footer – footer.php. It displays the footer section.

5- Theme Functions – functions.php. Contains code and functions which is used in a theme.

6- Single Post – single.php. Displays the single post page.

7- Comments – comments.php. It displays comments and comment form.

Templates can be included into each other.

For example, single.php can have header, footer and content template included into it. WordPress allows users to add as many as per their choice. WordPress additionally has a templates hierarchy. If a theme doesn’t have single.php then WordPress will automatically fall back to a more broad templates like index.php.