Wordpress 主题制作 - 文件层次结构
程序员文章站
2022-04-16 23:49:26
...
在制作主题之前,需要先了解Wordpress主题主要由哪些文件构成。
wordpress默认主题主要由以下文件组成:
文件介绍:
- 主样式文件
style.css
头部需要注释在仪表面板中显示有关主题的信息:
- Theme Name : 主题名称。
- Theme URI: 公共网页的URL,用户可以在其中找到有关该主题的更多信息。
- Author (*): 开发主题的个人或组织的名称。 建议使用主题作者的wordpress.org用户名。
- Author URI: 创作个人或组织的网址。
- Description (*): 简短描述的主题。
- Version (*): 该版本以X.X或X.X.X格式编写。
- License (*): 主题的协议。
- License URI (*): 主题许可证的URL。
- Text Domain (*): 用于文本域的字符串用于翻译。
- Tags: 允许用户使用标签过滤器查找主题的单词或短语。
注:(*)表示主题所必需的
例如:
/*
Theme Name: Twenty Seventeen
Theme URI: https://wordpress.org/themes/twentyseventeen/
Author: the WordPress team
Author URI: https://wordpress.org/
Description: Twenty Seventeen brings your site to life with immersive featured images and subtle animations. With a focus on business sites, it features multiple sections on the front page as well as widgets, navigation and social menus, a logo, and more. Personalize its asymmetrical grid with a custom color scheme and showcase your multimedia content with post formats. Our default theme for 2017 works great in many languages, for any abilities, and on any device.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: twentyseventeen
Tags: one-column, two-columns, right-sidebar, flexible-header, accessibility-ready, custom-colors, custom-header, custom-menu, custom-logo, editor-style, featured-images, footer-widgets, post-formats, rtl-language-support, sticky-post, theme-options, threaded-comments, translation-ready
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.
*/
- 首页
home.php
index.php
如找到home.php,使用home.php作为主页,无论是否有index.php
如果未找到home.php,使用index.php作为首页
- 文章页
single.php
single-{post_type}.php
post_type表示文章类型
- 分类
category-{slug}.php
category-{id}.php
category.php
如分类缩略名是news,会查找category-news.php
如分类的id是6,会查找category-6.php
- 标签
tag-{slug}.php
tag-{id}.php
tag.php
如分类缩略名为php,会查找tag-php.php
如分类id为5,会查找tag-5.php
- 日期页
date.php
- 作者
author-{nickname}.php
author-{id}.php
author.php
如作者昵称为ammy,会查找author.ammy.php
如作者id为5,会查找author-5.php
- 搜索页
search.php
- 归档页
archive.php
- 单页面
page-{slug}.php
page-{id}.php
page.php
分类缩略名为news,会查找page-news.php
分类id为5,会查找page-5.php
- 404页面
404.php
上一篇: Ajax从0到1