Tim Visher Tim Visher - 13 days ago 8
CSS Question

Is the syntax for the Wordpress style.css template element available anywhere?

I've recently embarked upon the grand voyage of Wordpress theming and I've been reading through the Wordpress documentation for how to write a theme. One thing I came across here was that the

style.css
file must contain a specific header in order to be used by the Wordpress engine. They give a brief example but I haven't been able to turn up any formal description of what must be in the
style.css
header portion. Does this exist on the Wordpress site? If it doesn't could we perhaps describe it here?

Answer

Based on http://codex.wordpress.org/Theme_Development:

The following is an example of the first few lines of the stylesheet, called the style sheet header, for the Theme "Rose":

/*   
Theme Name: Rose
Theme URI: the-theme's-homepage
Description: a-brief-description
Author: your-name
Author URI: your-URI
Template: use-this-to-define-a-parent-theme--optional
Version: a-number--optional
Tags: a-comma-delimited-list--optional
.
General comments/License Statement if any.
.
*/

The simplest Theme includes only a style.css file, plus images, if any. To create such a Theme, you must specify a set of templates to inherit for use with the Theme by editing the Template: line in the style.css header comments. For example, if you wanted the Theme "Rose" to inherit the templates from another Theme called "test", you would include Template: test in the comments at the beginning of Rose's style.css. Now "test" is the parent Theme for "Rose", which still consists only of a style.css file and the concomitant images, all located in the directory wp-content/themes/Rose. (Note that specifying a parent Theme will inherit all of the template files from that Theme — meaning that any template files in the child Theme's directory will be ignored.)

The comment header lines in style.css are required for WordPress to be able to identify a Theme and display it in the Administration Panel under Design > Themes as an available Theme option along with any other installed Themes.

The Theme Name, Version, Author, and Author URI fields are parsed by WordPress and used to display that data in the Current Theme area on the top line of the current theme information, where the Author's Name is hyperlinked to the Author URI. The Description and Tag fields are parsed and displayed in the body of the theme's information, and if the theme has a parent theme, that information is placed in the information body as well. In the Available Themes section, only the Theme Name, Description, and Tags fields are used.

None of these fields have any restrictions - all are parsed as strings. In addition, none of them are required in code, though in practice the fields not marked as optional in the list above are all used to provide contextual information to the WordPress administrator and should be included for all themes.

Comments