Wordpress 主题制作 - 文件层次结构

在制作主题之前,需要先了解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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值