WordPress主题文件 style.css

江河/ 2023年04月12日/ WordPress/ 浏览 2159

每个 WordPress 主题中都有一个 style.css 文件。css 是用来控制 web 页面的布局和样式的,这是css的本职工作。


WordPress主题 中的 style.css 还肩负着另一项任务。style.css 提供了 WordPress主题 的简介信息。


下面是 WordPress 自带主题 twentytwentythree 的 style.css 头部注释。


/*
Theme Name: Twenty Twenty-Three
Theme URI: https://wordpress.org/themes/twentytwentythree
Author: the WordPress team
Author URI: https://wordpress.org
Description: Twenty Twenty-Three is designed to take advantage of the new design tools introduced in WordPress 6.1. With a clean, blank base as a starting point, this default theme includes ten diverse style variations created by members of the WordPress community. Whether you want to build a complex or incredibly simple website, you can do it quickly and intuitively through the bundled styles or dive into creation and full customization yourself.
Requires at least: 6.1
Tested up to: 6.1
Requires PHP: 5.6
Version: 1.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
Text Domain: twentytwentythree
Tags: one-column, custom-colors, custom-menu, custom-logo, editor-style, featured-images, full-site-editing, block-patterns, rtl-language-support, sticky-post, threaded-comments, translation-ready, wide-blocks, block-styles, accessibility-ready, blog, portfolio, news
*/


这些注释提供了主题的名字、适用版本、基本功能、特性、协议等信息。如果我们开发自己的主题,也必须要提供这些信息才行,这是一个WordPress主题所必需的信息。


如果是一个WordPress子主题,style.css 中则必须指明继承的是哪个主题。


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


Template:twentytwenty。说明这个子主题继承的主题目录是 twentytwenty 。


发表评论

暂无评论,抢个沙发...

客服 工单