Theme Development Standards
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 .
- 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 achild of another theme which acts as its parent.
For a detailed guide to child themes, see .
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 , as this will lead to problems in the . 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 Ten":
/* Theme Name: Twenty Ten Theme URI: http://wordpress.org/ Description: The 2010 default theme for WordPress. Author: wordpressdotorg Author URI: http://wordpress.org/ Version: 1.0 Tags: black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style, custom-menu (optional) License: License URI: General comments (optional). */
NB: The name used for the Author is suggested to be the same as the Theme Author's wordpress.org username, although it can be the author's real name as well. The choice is the Theme Author's.