科研编程
中风险
WordPress 主题开发工作流
本技能描述创建 WordPress 主题的完整工作流程,涵盖主题架构、模板层次结构、自定义文章类型、块编辑器支持、响应式设计,以及 WordPress 7.0 的新特性:DataViews、模式编辑、导航叠加层和后台刷新。
文件预览
1 个文件
SKILL.md
12.8 KB · 可预览
---
name: wordpress-theme-development
description: "WordPress theme development workflow covering theme architecture, template hierarchy, custom post types, block editor support, responsive design, and WordPress 7.0 features: DataViews, Pattern Editing, Navigation Overlays, and admin refresh."
category: granular-workflow-bundle
risk: safe
source: personal
date_added: "2026-02-27"
---
# WordPress Theme Development Workflow
## Overview
Specialized workflow for creating custom WordPress themes from scratch, including modern block editor (Gutenberg) support, template hierarchy, responsive design, and WordPress 7.0 enhancements.
## WordPress 7.0 Theme Features
1. **Admin Refresh**
- New default color scheme
- View transitions between admin screens
- Modern typography and spacing
2. **Pattern Editing**
- ContentOnly mode defaults for unsynced patterns
- `disableContentOnlyForUnsyncedPatterns` setting
- Per-block instance custom CSS
3. **Navigation Overlays**
- Customizable navigation overlays
- Improved mobile navigation
4. **New Blocks**
- Icon block
- Breadcrumbs block with filters
- Responsive grid block
5. **Theme.json Enhancements**
- Pseudo-element support
- Block-defined feature selectors honored
- Enhanced custom CSS
6. **Iframed Editor**
- Block API v3+ enables iframed post editor
- Full enforcement in 7.1, opt-in in 7.0
## When to Use This Workflow
Use this workflow when:
- Creating custom WordPress themes
- Converting designs to WordPress themes
- Adding block editor support
- Implementing custom post types
- Building child themes
- Implementing WordPress 7.0 design features
## Workflow Phases
### Phase 1: Theme Setup
#### Skills to Invoke
- `app-builder` - Project scaffolding
- `frontend-developer` - Frontend development
#### Actions
1. Create theme directory structure
2. Set up style.css with theme header
3. Create functions.php
4. Configure theme support
5. Set up enqueue scripts/styles
#### WordPress 7.0 Theme Header
```css
/*
Theme Name: My Custom Theme
Theme URI: https://example.com
Author: Developer Name
Author URI: https://example.com
Description: A WordPress 7.0 compatible theme with modern design
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 7.4
License: GNU General Public License v2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: my-custom-theme
Tags: block-patterns, block-styles, editor-style, wide-blocks
*/
```
#### Copy-Paste Prompts
```
Use @app-builder to scaffold a new WordPress theme project
```
### Phase 2: Template Hierarchy
#### Skills to Invoke
- `frontend-developer` - Template development
#### Actions
1. Create index.php (fallback template)
2. Implement header.php and footer.php
3. Create single.php for posts
4. Create page.php for pages
5. Add archive.php for archives
6. Implement search.php and 404.php
#### WordPress 7.0 Template Considerations
- Test with iframed editor
- Verify view transitions work
- Check new admin color scheme compatibility
#### Copy-Paste Prompts
```
Use @frontend-developer to create WordPress template files
```
### Phase 3: Theme Functions
#### Skills to Invoke
- `backend-dev-guidelines` - Backend patterns
#### Actions
1. Register navigation menus
2. Add theme support (thumbnails, RSS, etc.)
3. Register widget areas
4. Create custom template tags
5. Implement helper functions
#### WordPress 7.0 theme.json Configuration
```json
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 3,
"settings": {
"appearanceTools": true,
"layout": {
"contentSize": "1200px",
"wideSize": "1400px"
},
"background": {
"backgroundImage": true
},
"typography": {
"fontFamilies": true,
"fontSizes": true
},
"spacing": {
"margin": true,
"padding": true
},
"blocks": {
"core/heading": {
"typography": {
"fontSizes": ["24px", "32px", "48px"]
}
}
}
},
"styles": {
"color": {
"background": "#ffffff",
"text": "#1a1a1a"
},
"elements": {
"link": {
"color": {
"text": "#0066cc"
}
}
}
},
"customTemplates": [
{
"name": "page-home",
"title": "Homepage",
"postTypes": ["page"]
}
],
"templateParts": [
{
"name": "header",
"title": "Header",
"area": "header"
}
]
}
```
#### Copy-Paste Prompts
```
Use @backend-dev-guidelines to create theme functions
```
### Phase 4: Custom Post Types
#### Skills to Invoke
- `wordpress-penetration-testing` - WordPress patterns
#### Actions
1. Register custom post types
2. Create custom taxonomies
3. Add custom meta boxes
4. Implement custom fields
5. Create archive templates
#### RTC-Compatible CPT Registration
```php
register_post_type('portfolio', [
'labels' => [
'name' => __('Portfolio', 'my-theme'),
'singular_name' => __('Portfolio Item', 'my-theme')
],
'public' => true,
'has_archive' => true,
'show_in_rest' => true, // Enable for RTC
'supports' => ['title', 'editor', 'thumbnail', 'excerpt', 'custom-fields'],
'menu_icon' => 'dashicons-portfolio',
]);
// Register meta for collaboration
register_post_meta('portfolio', 'client_name', [
'type' => 'string',
'single' => true,
'show_in_rest' => true,
'sanitize_callback' => 'sanitize_text_field',
]);
```
#### Copy-Paste Prompts
```
Use @wordpress-penetration-testing to understand WordPress CPT patterns
```
### Phase 5: Block Editor Support
#### Skills to Invoke
- `frontend-developer` - Block development
#### Actions
1. Enable block editor support
2. Register custom blocks
3. Create block styles
4. Add block patterns
5. Configure block templates
#### WordPress 7.0 Block Features
- Block API v3 is reference model
- PHP-only block registration
- Per-instance custom CSS
- Block visibility controls (viewport-based)
#### Block Pattern with ContentOnly (WP 7.0)
```json
{
"name": "my-theme/hero-section",
"title": "Hero Section",
"contentOnly": true,
"content": [
{
"name": "core/cover",
"attributes": {
"url": "{{hero_image}}",
"overlay": "black",
"dimRatio": 50
},
"innerBlocks": [
{
"name": "core/heading",
"attributes": {
"level": 1,
"textAlign": "center",
"content": "{{hero_title}}"
}
},
{
"name": "core/paragraph",
"attributes": {
"align": "center",
"content": "{{hero_description}}"
}
}
]
}
]
}
```
#### Navigation Overlay Template Part
```php
// template-parts/header-overlay.php
?>
<nav class="header-navigation-overlay" aria-label="<?php esc_attr_e('Overlay Menu', 'my-theme'); ?>">
<button class="overlay-close" aria-label="<?php esc_attr_e('Close menu', 'my-theme'); ?>">
<span class="close-icon" aria-hidden="true">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
</span>
</button>
<?php
wp_nav_menu([
'theme_location' => 'primary',
'container' => false,
'menu_class' => 'overlay-menu',
'fallback_cb' => false,
]);
?>
</nav>
```
#### Copy-Paste Prompts
```
Use @frontend-developer to create custom Gutenberg blocks
```
### Phase 6: Styling and Design
#### Skills to Invoke
- `frontend-design` - UI design
- `tailwind-patterns` - Tailwind CSS
#### Actions
1. Implement responsive design
2. Add CSS framework or custom styles
3. Create design system
4. Implement theme customizer
5. Add accessibility features
#### WordPress 7.0 Admin Refresh Considerations
```css
/* Support new admin color scheme */
@media (prefers-color-scheme: dark) {
:root {
--admin-color: modern;
}
}
/* View transitions */
.wp-admin {
view-transition-name: none;
}
body {
view-transition-name: page;
}
```
#### CSS Custom Properties (WP 7.0)
```css
:root {
/* New DataViews colors */
--wp-dataviews-color-background: #ffffff;
--wp-dataviews-color-border: #e0e0e0;
/* Navigation overlay */
--wp-overlay-menu-background: #1a1a1a;
--wp-overlay-menu-text: #ffffff;
}
```
#### Copy-Paste Prompts
```
Use @frontend-design to create responsive theme design
```
### Phase 7: WordPress 7.0 Features Integration
#### Breadcrumbs Block Support
```php
// Add breadcrumb filters for custom post types
add_filter('wp_breadcrumb_args', function($args) {
$args['separator'] = '<span class="breadcrumb-separator"> / </span>';
$args['before'] = '<nav class="breadcrumb" aria-label="Breadcrumb">';
$args['after'] = '</nav>';
return $args;
});
// Add custom breadcrumb trail for CPT
add_action('breadcrumb_items', function($trail, $crumbs) {
if (is_singular('portfolio')) {
$portfolio_page = get_page_by_path('portfolio');
if ($portfolio_page) {
array_splice($trail->crumbs, 1, 0, [
[
'title' => get_the_title($portfolio_page),
'url' => get_permalink($portfolio_page)
]
]);
}
}
}, 10, 2);
```
#### Icon Block Support
```php
// Add custom icons for Icon block via pattern category
add_action('init', function() {
register_block_pattern_category('my-theme/icons', [
'label' => __('Theme Icons', 'my-theme'),
'description' => __('Custom icons for use in the Icon block', 'my-theme'),
]);
});
// For actual SVG icons in the Icon block, use block.json or PHP registration
add_action('init', function() {
register_block_pattern('my-theme/custom-icons', [
'title' => __('Custom Icon Set', 'my-theme'),
'categories' => ['my-theme/icons'],
'content' => '<!-- Pattern content with Icon blocks -->'
]);
});
```
### Phase 8: Testing
#### Skills to Invoke
- `playwright-skill` - Browser testing
- `webapp-testing` - Web app testing
#### Actions
1. Test across browsers
2. Verify responsive breakpoints
3. Test block editor
4. Check accessibility
5. Performance testing
#### WordPress 7.0 Testing Checklist
- [ ] Test with iframed editor
- [ ] Verify view transitions
- [ ] Check admin color scheme
- [ ] Test navigation overlays
- [ ] Verify contentOnly patterns
- [ ] Test breadcrumbs on CPT archives
#### Copy-Paste Prompts
```
Use @playwright-skill to test WordPress theme
```
## Theme Structure
```
theme-name/
├── style.css
├── functions.php
├── index.php
├── header.php
├── footer.php
├── sidebar.php
├── single.php
├── page.php
├── archive.php
├── search.php
├── 404.php
├── comments.php
├── template-parts/
│ ├── header/
│ ├── footer/
│ ├── navigation/
│ └── content/
├── patterns/ # Block patterns (WP 7.0)
├── templates/ # Site editor templates
├── inc/
│ ├── class-theme.php
│ └── supports.php
├── assets/
│ ├── css/
│ ├── js/
│ └── images/
└── languages/
```
## WordPress 7.0 Theme Checklist
- [ ] PHP 7.4+ requirement documented
- [ ] theme.json v3 schema used
- [ ] Block patterns tested
- [ ] ContentOnly editing supported
- [ ] Navigation overlays implemented
- [ ] Breadcrumb filters added for CPT
- [ ] View transitions working
- [ ] Admin refresh compatible
- [ ] CPT meta shows_in_rest
- [ ] Iframe editor tested
## Quality Gates
- [ ] All templates working
- [ ] Block editor supported
- [ ] Responsive design verified
- [ ] Accessibility checked
- [ ] Performance optimized
- [ ] Cross-browser tested
- [ ] WordPress 7.0 compatibility verified
## Related Workflow Bundles
- `wordpress` - WordPress development
- `wordpress-plugin-development` - Plugin development
- `wordpress-woocommerce` - WooCommerce
## Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
SKILL.md
元数据
| name | wordpress-theme-development |
|---|---|
| description | WordPress 主题开发工作流,涵盖主题架构、模板层次结构、自定义文章类型、块编辑器支持、响应式设计,以及 WordPress 7.0 功能:DataViews、模式编辑、导航叠加层和后台刷新。 |
| category | granular-workflow-bundle |
| risk | safe |
| source | personal |
| date_added | 2026-02-27 |
WordPress 主题开发工作流
概述
用于从零创建自定义 WordPress 主题的专用工作流,包括现代块编辑器(Gutenberg)支持、模板层次结构、响应式设计和 WordPress 7.0 增强功能。
WordPress 7.0 主题特性
-
后台刷新
- 新的默认配色方案
- 后台界面之间的视图过渡
- 现代排版和间距
-
模式编辑
- ContentOnly 模式默认为非同步模式
disableContentOnlyForUnsyncedPatterns设置- 每个块的实例自定义 CSS
-
导航叠加层
- 可自定义的导航叠加层
- 改进的移动导航
-
新块
- 图标块
- 面包屑块(带过滤器)
- 响应式网格块
-
theme.json 增强
- 伪元素支持
- 块定义的功能选择器得到遵守
- 增强的自定义 CSS
-
内嵌编辑器
- 块 API v3+ 支持内嵌文章编辑器
- 7.1 全面强制使用,7.0 中可选
何时使用本工作流
在以下情况下使用本工作流:
- 创建自定义 WordPress 主题
- 将设计转换为 WordPress 主题
- 添加块编辑器支持
- 实现自定义文章类型
- 构建子主题
- 实现 WordPress 7.0 设计特性
工作流阶段
阶段 1:主题搭建
调用技能
app-builder- 项目脚手架frontend-developer- 前端开发
操作
- 创建主题目录结构
- 使用主题头部设置 style.css
- 创建 functions.php
- 配置主题支持
- 设置脚本/样式的入队
WordPress 7.0 主题头部
css
/*
Theme Name: My Custom Theme
Theme URI: https://example.com
Author: Developer Name
Author URI: https://example.com
Description: A WordPress 7.0 compatible theme with modern design
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 7.4
License: GNU General Public License v2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: my-custom-theme
Tags: block-patterns, block-styles, editor-style, wide-blocks
*/复制-粘贴提示
text
使用 @app-builder 搭建一个新的 WordPress 主题项目阶段 2:模板层次结构
调用技能
frontend-developer- 模板开发
操作
- 创建 index.php(回退模板)
- 实现 header.php 和 footer.php
- 为文章创建 single.php
- 为页面创建 page.php
- 为归档添加 archive.php
- 实现 search.php 和 404.php
WordPress 7.0 模板注意事项
- 使用内嵌编辑器进行测试
- 验证视图过渡工作正常
- 检查新后台配色方案的兼容性
复制-粘贴提示
text
使用 @frontend-developer 创建 WordPress 模板文件阶段 3:主题函数
调用技能
backend-dev-guidelines- 后端模式
操作
- 注册导航菜单
- 添加主题支持(缩略图、RSS 等)
- 注册小工具区域
- 创建自定义模板标签
- 实现辅助函数
WordPress 7.0 theme.json 配置
json
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 3,
"settings": {
"appearanceTools": true,
"layout": {
"contentSize": "1200px",
"wideSize": "1400px"
},
"background": {
"backgroundImage": true
},
"typography": {
"fontFamilies": true,
"fontSizes": true
},
"spacing": {
"margin": true,
"padding": true
},
"blocks": {
"core/heading": {
"typography": {
"fontSizes": ["24px", "32px", "48px"]
}
}
}
},
"styles": {
"color": {
"background": "#ffffff",
"text": "#1a1a1a"
},
"elements": {
"link": {
"color": {
"text": "#0066cc"
}
}
}
},
"customTemplates": [
{
"name": "page-home",
"title": "Homepage",
"postTypes": ["page"]
}
],
"templateParts": [
{
"name": "header",
"title": "Header",
"area": "header"
}
]
}复制-粘贴提示
text
使用 @backend-dev-guidelines 创建主题函数阶段 4:自定义文章类型
调用技能
wordpress-penetration-testing- WordPress 模式
操作
- 注册自定义文章类型
- 创建自定义分类法
- 添加自定义元框
- 实现自定义字段
- 创建归档模板
兼容 RTC 的自定义文章类型注册
php
register_post_type('portfolio', [
'labels' => [
'name' => __('Portfolio', 'my-theme'),
'singular_name' => __('Portfolio Item', 'my-theme')
],
'public' => true,
'has_archive' => true,
'show_in_rest' => true, // 为 RTC 启用
'supports' => ['title', 'editor', 'thumbnail', 'excerpt', 'custom-fields'],
'menu_icon' => 'dashicons-portfolio',
]);
// 为协作注册元数据
register_post_meta('portfolio', 'client_name', [
'type' => 'string',
'single' => true,
'show_in_rest' => true,
'sanitize_callback' => 'sanitize_text_field',
]);复制-粘贴提示
text
使用 @wordpress-penetration-testing 理解 WordPress CPT 模式阶段 5:块编辑器支持
调用技能
frontend-developer- 块开发
操作
- 启用块编辑器支持
- 注册自定义块
- 创建块样式
- 添加块模式
- 配置块模板
WordPress 7.0 块特性
- 块 API v3 是参考模型
- 仅 PHP 的块注册
- 每个实例的自定义 CSS
- 块可见性控制(基于视口)
带 ContentOnly 的块模式(WP 7.0)
json
{
"name": "my-theme/hero-section",
"title": "Hero Section",
"contentOnly": true,
"content": [
{
"name": "core/cover",
"attributes": {
"url": "{{hero_image}}",
"overlay": "black",
"dimRatio": 50
},
"innerBlocks": [
{
"name": "core/heading",
"attributes": {
"level": 1,
"textAlign": "center",
"content": "{{hero_title}}"
}
},
{
"name": "core/paragraph",
"attributes": {
"align": "center",
"content": "{{hero_description}}"
}
}
]
}
]
}导航叠加层模板部件
php
// template-parts/header-overlay.php
?>
<nav class="header-navigation-overlay" aria-label="<?php esc_attr_e('Overlay Menu', 'my-theme'); ?>">
<button class="overlay-close" aria-label="<?php esc_attr_e('Close menu', 'my-theme'); ?>">
<span class="close-icon" aria-hidden="true">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
</span>
</button>
<?php
wp_nav_menu([
'theme_location' => 'primary',
'container' => false,
'menu_class' => 'overlay-menu',
'fallback_cb' => false,
]);
?>
</nav>复制-粘贴提示
text
使用 @frontend-developer 创建自定义 Gutenberg 块阶段 6:样式与设计
调用技能
frontend-design- UI 设计tailwind-patterns- Tailwind CSS
操作
- 实现响应式设计
- 添加 CSS 框架或自定义样式
- 创建设计系统
- 实现主题自定义器
- 添加无障碍特性
WordPress 7.0 后台刷新注意事项
css
/* 支持新的后台配色方案 */
@media (prefers-color-scheme: dark) {
:root {
--admin-color: modern;
}
}
/* 视图过渡 */
.wp-admin {
view-transition-name: none;
}
body {
view-transition-name: page;
}CSS 自定义属性(WP 7.0)
css
:root {
/* 新增 DataViews 颜色 */
--wp-dataviews-color-background: #ffffff;
--wp-dataviews-color-border: #e0e0e0;
/* 导航叠加层 */
--wp-overlay-menu-background: #1a1a1a;
--wp-overlay-menu-text: #ffffff;
}复制-粘贴提示
text
使用 @frontend-design 创建响应式主题设计阶段 7:集成 WordPress 7.0 特性
面包屑块支持
php
// 为自定义文章类型添加面包屑过滤器
add_filter('wp_breadcrumb_args', function($args) {
$args['separator'] = '<span class="breadcrumb-separator"> / </span>';
$args['before'] = '<nav class="breadcrumb" aria-label="Breadcrumb">';
$args['after'] = '</nav>';
return $args;
});
// 为 CPT 添加自定义面包屑路径
add_action('breadcrumb_items', function($trail, $crumbs) {
if (is_singular('portfolio')) {
$portfolio_page = get_page_by_path('portfolio');
if ($portfolio_page) {
array_splice($trail->crumbs, 1, 0, [
[
'title' => get_the_title($portfolio_page),
'url' => get_permalink($portfolio_page)
]
]);
}
}
}, 10, 2);图标块支持
php
// 通过模式类别为图标块添加自定义图标
add_action('init', function() {
register_block_pattern_category('my-theme/icons', [
'label' => __('Theme Icons', 'my-theme'),
'description' => __('Custom icons for use in the Icon block', 'my-theme'),
]);
});
// 对于图标块中的实际 SVG 图标,使用 block.json 或 PHP 注册
add_action('init', function() {
register_block_pattern('my-theme/custom-icons', [
'title' => __('Custom Icon Set', 'my-theme'),
'categories' => ['my-theme/icons'],
'content' => '<!-- Pattern content with Icon blocks -->'
]);
});阶段 8:测试
调用技能
playwright-skill- 浏览器测试webapp-testing- Web 应用测试
操作
- 跨浏览器测试
- 验证响应式断点
- 测试块编辑器
- 检查无障碍性
- 性能测试
WordPress 7.0 测试检查清单
- 使用内嵌编辑器测试
- 验证视图过渡
- 检查后台配色方案
- 测试导航叠加层
- 验证 contentOnly 模式
- 在 CPT 归档上测试面包屑
复制-粘贴提示
text
使用 @playwright-skill 测试 WordPress 主题主题结构
text
theme-name/
├── style.css
├── functions.php
├── index.php
├── header.php
├── footer.php
├── sidebar.php
├── single.php
├── page.php
├── archive.php
├── search.php
├── 404.php
├── comments.php
├── template-parts/
│ ├── header/
│ ├── footer/
│ ├── navigation/
│ └── content/
├── patterns/ # 块模式(WP 7.0)
├── templates/ # 站点编辑器模板
├── inc/
│ ├── class-theme.php
│ └── supports.php
├── assets/
│ ├── css/
│ ├── js/
│ └── images/
└── languages/WordPress 7.0 主题检查清单
- 文档中注明 PHP 7.4+ 要求
- 使用 theme.json v3 模式
- 块模式已测试
- 支持 ContentOnly 编辑
- 导航叠加层已实现
- 为 CPT 添加了面包屑过滤器
- 视图过渡工作正常
- 后台刷新兼容
- CPT 元数据 show_in_rest
- 内嵌编辑器已测试
质量关卡
- 所有模板工作正常
- 支持块编辑器
- 验证响应式设计
- 检查无障碍性
- 性能优化
- 跨浏览器测试
- 验证 WordPress 7.0 兼容性
相关工作流包
wordpress- WordPress 开发wordpress-plugin-development- 插件开发wordpress-woocommerce- WooCommerce
限制
- 仅在任务明确匹配上述范围时使用此技能。
- 不要将输出视为特定环境验证、测试或专家评审的替代品。
- 如果缺少所需输入、权限、安全边界或成功标准,请停止并请求澄清。