3

我最近开始了 Wordpress 主题的盛大之旅,我一直在阅读 Wordpress 文档以了解如何编写主题。我在这里遇到的一件事是该style.css文件必须包含特定的标题才能被 Wordpress 引擎使用。他们给出了一个简短的例子,但我无法对style.css标题部分必须包含的内容进行任何正式描述。这在 Wordpress 网站上是否存在?如果不能,我们可以在这里描述它吗?

4

2 回答 2

7

基于http://codex.wordpress.org/Theme_Development

以下是样式表前几行的示例,称为样式表标题,用于主题“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.
.
*/

最简单的主题只包含一个 style.css 文件,如果有的话,还包括图片。要创建这样的主题,您必须通过编辑 style.css 标题注释中的 Template: 行来指定要继承的一组模板以与主题一起使用。例如,如果您希望主题“Rose”从另一个名为“test”的主题继承模板,您可以在 Rose 的 style.css 开头的注释中包含 Template:test。现在“test”是“Rose”的父主题,它仍然只包含一个 style.css 文件和伴随的图像,所有这些都位于目录 wp-content/themes/Rose 中。(请注意,指定父主题将继承该主题的所有模板文件——这意味着子主题目录中的任何模板文件都将被忽略。)

WordPress 需要 style.css 中的注释标题行才能识别主题并将其显示在“设计”>“主题”下的“管理面板”中,作为可用的主题选项以及任何其他已安装的主题。

主题名称、版本、作者和作者 URI 字段由 WordPress 解析,并用于在当前主题信息顶行的当前主题区域中显示该数据,其中作者姓名超链接到作者 URI。描述和标签字段被解析并显示在主题信息的主体中,如果主题有父主题,则该信息也被放置在信息主体中。在可用主题部分中,仅使用主题名称、描述和标签字段。

None of these fields have any restrictions - all are parsed as strings. In addition, none of them are required in the 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.

于 2008-09-17T19:44:12.943 回答
1

你可能在想这个:

/*
THEME NAME: Parallax
THEME URI: http://parallaxdenigrate.net
VERSION: .1
AUTHOR: Martin Jacobsen
AUTHOR URI: http://martinjacobsen.no
*/

如果我没有离开,Wordpress 会使用此信息显示在管理后端的“激活设计”对话框中。

于 2008-09-17T19:42:40.170 回答