一个最精简且完整的 WordPress 主题,仅要求主题目录下必须有 style.css 和 index.php 两个文件。
一个功能完整可用的 WordPress 主题文件则可以无限多。文件多,又几乎没啥要求,就容易乱……
开发主题时最好是遵守一定规则,比如 twentyseventeen 主题的目录结构如下:
.
├── assets (dir)/
│ ├── css (dir)
│ ├── images (dir)
│ └── js (dir)
├── inc (dir)
├── template-parts (dir)/
│ ├── footer (dir)
│ ├── header (dir)
│ ├── navigation (dir)
│ ├── page (dir)
│ └── post (dir)
├── 404.php
├── archive.php
├── comments.php
├── footer.php
├── front-page.php
├── functions.php
├── header.php
├── index.php
├── page.php
├── README.txt
├── rtl.css
├── screenshot.png
├── search.php
├── searchform.php
├── sidebar.php
├── single.php
└── style.css
经典 WordPress 主题中,模板文件都在主题的根目录下--子目录中的文件都是被模板文件包含的,子目录及子目录中的文件都可以自由命名。
块主题中,模板文件要求必须在子目录 templates 下,模板块则必须在 parts 子目录下。要求比经典主题多了一点点。
-
WordPress函数:wp_enqueue_code_editor 引入代码编辑器需要的js和cssWordPress函数:wp_enqueue_code_editor 引入代码编辑器需要的js和css
-
WordPress函数:wp_enqueue_block_style 为特定块引入样式表WordPress函数:wp_enqueue_block_style 为特定块引入样式表
-
WordPress函数:wp_enqueue_global_styles 引入theme.json定义的全局样式WordPress函数:wp_enqueue_global_styles 引入theme.json定义的全局样式
-
WordPress函数:wp_enqueue_stored_styles 处理核心样式合并到页面中WordPress函数:wp_enqueue_stored_styles 处理核心样式合并到页面中
-
WordPress教程菜鸟教程之WordPress主题和插件开发追格小编同学已经撰写并分享过一些相关的教程,包括WordPress主题开发教程和WordPress插件开发教程。
-
WordPress主题国际化WordPress主题国际化
暂无评论,抢个沙发...