WordPress Themes should be coded using the following standards:
- Use well-structured, error-free PHP and valid HTML. See WordPress Coding Standards.
- Use clean, valid CSS. See CSS Coding Standards.
- Follow design guidelines in Site Design and Layout.
Anatomy of a Theme
WordPress includes a default theme in each new installation. Examine the files in the default theme carefully to get a better idea of how to build your own Theme files.
For a visual guide, see this infographic on WordPress Theme Anatomy.
- The stylesheet called style.css, which controls the presentation (visual design and layout) of the website pages.
- WordPress template files which control the way the site pages generate the information from your WordPress database to be displayed on the site.
- The optional functions file (functions.php) as part of the WordPress Theme files.
Let’s look at these individually.
The simplest Theme possible is a child theme which includes only a style.css file, plus any images. This is possible because it is a child of another theme which acts as its parent.
For a detailed guide to child themes, see Child Themes.
In addition to CSS style information for your theme, style.css provides details about the Theme in the form of comments. The stylesheet must provide details about the Theme in the form of comments. No two Themes are allowed to have the same detailslisted in their comment headers, as this will lead to problems in the Theme selection dialog. If you make your own Theme by copying an existing one, make sure you change this information first.
The following is an example of the first few lines of the stylesheet, called the stylesheet header, for the Theme “Twenty Thirteen”: