wordpress主题开发之《主样式表 (style.css)》文件说明

前言

style.css 是每个 WordPress 主题所需的样式表 (CSS) 文件。它控制网站页面的展示效果。为了让 WordPress 将主题模板文件集识别为有效主题,style.css 文件需要位于主题的根目录中,而不是子目录中。

主样式表 (style.css)编写格式

WordPress 使用 style.css 的标题注释部分在外观(主题)仪表板面板中显示有关主题的信息。

例如

/*
Theme Name: Twenty Twenty
Theme URI: https://wordpress.org/themes/twentytwenty/
Author: the WordPress team
Author URI: https://wordpress.org/
Description: Our default theme for 2020 is designed to take full advantage of the flexibility of the block editor. Organizations and businesses have the ability to create dynamic landing pages with endless layouts using the group and column blocks. The centered content column and fine-tuned typography also makes it perfect for traditional blogs. Complete editor styles give you a good idea of what your content will look like, even before you publish. You can give your site a personal touch by changing the background colors and the accent color in the Customizer. The colors of all elements on your site are automatically calculated based on the colors you pick, ensuring a high, accessible color contrast for your visitors.
Tags: blog, one-column, custom-background, custom-colors, custom-logo, custom-menu, editor-style, featured-images, footer-widgets, full-width-template, rtl-language-support, sticky-post, theme-options, threaded-comments, translation-ready, block-styles, wide-blocks, accessibility-ready
Version: 1.3
Requires at least: 5.0
Tested up to: 5.4
Requires PHP: 7.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: twentytwenty
This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you've learned with others.
*/

 对应中文解释

 

带有 ( * ) 的项目是 WordPress 主题存储库中的主题所必需的。

主题名称(*):主题的名称。
主题 URI:公共网页的 URL,用户可以在其中找到有关主题的更多信息。
作者(*):开发主题的个人或组织的名称。建议使用主题作者的 wordpress.org 用户名。
作者 URI:创作个人或组织的 URL。
描述(*):主题的简短描述。
版本(*):主题的版本,以 XX 或 XXX 格式编写。
至少需要 (*):主题将使用的最旧的主 WordPress 版本,以 XX 格式编写。主题只需要支持最后三个版本。
测试到 (*):主题已测试到的最后一个主要 WordPress 版本,即 5.4。只写数字,XX 格式。
Requires PHP (*) : 支持的最旧的 PHP 版本,XX 格式,只有数字
许可证(*):主题的许可证。
许可证 URI (*):主题许可证的 URL。
文本域(*):用于文本域进行翻译的字符串。
标签:允许用户使用标签过滤器找到主题的单词或短语。完整的标签列表在Theme Review Handbook中。
域路径:用于使 WordPress 在主题被禁用时知道在哪里可以找到翻译。默认为/languages.

 

注意

如果您的主题是子主题,则 style.css 标头中需要Template行。

/*
Theme Name: My Child Theme
Template: twentytwenty
*/

 

版权声明:
作者:小何
链接:https://ligo100.cn/qianduanjishu/ui/292.html
来源:小何博客
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
< <上一篇
下一篇>>
文章目录
关闭
目 录