Understanding WordPress Theme Files

In order to create quality a WordPress theme, a web developer must completely understand how the WordPress theme system works. In this article find out more about the categorization of WordPress theme files.

slide 1 of 5

Introduction

Every WordPress theme consists of two or more theme files. Only two files, index.php and style.css are absolutely necessary, but a theme with only these two files is rarely seen. There are some common WordPress theme files which the majority of themes use. Their names are known to anyone who has ever created (coded) at least one website: header.php, footer.php, sidebar.php, etc. Predefined theme files can be grouped into four groups: core, standard, special and junk. There is only one junk theme file (comments-popup.php), used rarely for enabling popup comments and as such, it will not be considered within this article.

slide 2 of 5

Core Files

As mentioned in the introduction, a fully functional WordPress theme needs only two files. These files are known as WordPress core files and as such, they are essential to every WordPress theme. The first file is index.php, which is used (in absence of home.php file) as a home page. The other file is style.css, which contains CSS styling information: even if no CSS style is included within, the file must be placed inside the theme directory. If either of these two files is missing, WordPress will not recognize the theme at all. Therefore, these two files are the first thing that every developer should create within the theme development process.

slide 3 of 5

Standard Files

Although not required, standard files are used in most themes. Some of their names (such as archive.php, comments.php, search.php, sidebar.php) are well-known to both web developers and regular Internet and WordPress users. A list of commonly used standard files and corresponding descriptions follows:

Additionally, there are a screenshot.png file and an “images“ folder. The screenshot.png file contains the screenshot of the theme and so shows up in the theme picker inside the WordPress admin section. It is also a very good habit to include an “images“ folder in which are put all the theme's images.

slide 4 of 5

Special Files

Finally, there are special files; these are optional additions which enhance the functionality of the WordPress theme. For example, the functions.php file is seen very often, especially as part of advanced themes. PHP functions that exist inside functions.php can control many aspects of how the website is rendered. Some other examples of special files are links.php, controlling the blogroll template, and rtl.css which contains instructions for the rendering of “right to left” languages.

slide 5 of 5

Further Reading

Every developer should understand the hierarchy of WordPress theme files in order to maximize the potential of WordPress templating. Fortunately, the official WordPress documentation site provides an excellent diagram on how template files are called to generate a WordPress page. Every beginner developer should have this diagram in front of her or his computer before the development process even starts.