Any theme for WordPress is a set of files. And each file is fulfilling its role. In today’s article we expand everything on the shelves and to define the hierarchy of files for WordPress theme.

First let us define with how WP handles page. When the page loads, it checks to see which type it is for example home, category, archive, single record, etc., Then it uses the appropriate template file for a specific page. If the page does not need a template, then it uses the parent file in the WordPress hierarchy. In wordPress hierarchy index.php is on the highest level and it is mandatory for any WP themes.

wordpress file structure explained

File structure for WordPress pages

Minimal theme consists of two files: index.php and style.css. Style.css is cascading style sheet. In this file there is information on the topic, on the first line. Like this:

CSS style sheet

Theme Name: ssiddique
Theme URI:
Description: Best wordpress theme
Author: Shabina Siddique
Author URI:
Template: Nice wordpress template
Version: Version 2.1

Page templates structure for WordPress

Pages are retrieved and designed based on these templates.

  • index.php is the basic template file. it is responsible for displaying the main main page and other types of pages if there is no corresponding template for them.
  • home.php-this is the template for the main page. It differs from the index.php in a way that it only works on the home and is not a replacement for other types of pages. If you need a unique key, then use this file.
  • page.php is a page template. It shows the entries for all the pages
  • single.php is use to create single page for each entry and show full post on one page.
  • archive.php is archive page template is also responsible for the appearance of headings, tags, author, date, if there is no corresponding template file available for them
  • search.php-search results page template.
  • 404 error page-404.php, when page is not found.
  • category.php template columns.
  • tag.php template tags.
  • author.php-author’s template.

Additional templates structure for WordPress theme

These templates are not recommended and let you insert duplicate page elements using a single line.

  • searchform.php: search form itself, what it will look like. Connect command
  • comments.php-view comments. Connect command
  • header.php file caps site. Connect command
  • footer.php file basement site, everything from the bottom. Connect command
  • functions.php-this file, the other is discrete from several, because through it you can add your own functionality or connect widgets or write your widget and more. He shall not be liable for any template page.

Page template structure for WordPress theme

A special place is given to the templates page. To understand what it is, go to edit theme and look to the right, select the page template (of course, if your theme supports it else you can’t find it). Create a simple page for example: page-simple.php and add following text at the very top of the file.

All template is connected, then you can write unique view of the page. Very convenient.

There are also other ways to to create page template. By using the id or slaga existing page. To do this, you must create the file: page-{slug or id} .php. For a page with the slug page simple-a unique template will look like page-simple-page.php.