wp-block-themes

作者: wordpress

WordPress区块主题开发:theme.json、模板、样式块及站点编辑器故障排查。涵盖theme.json编辑(预设、设置、逐块样式)、模板与模板部件、样式块及WordPress 6.9+版本中的样式变体。包含用于检测主题根目录和区块主题结构的分类脚本,以及创建新主题或转换经典主题的引导流程。提供样式层级问题、用户自定义覆盖及站点编辑器调试的工作流程。

npx skills add https://github.com/wordpress/agent-skills --skill wp-block-themes

WP Block Themes

When to use

Use this skill for block theme work such as:

  • editing theme.json (presets, settings, styles, per-block styles)
  • adding or changing templates (templates/*.html) and template parts (parts/*.html)
  • adding patterns (patterns/*.php) and controlling what appears in the inserter
  • adding style variations (styles/*.json)
  • debugging “styles not applying” / “editor doesn’t reflect theme.json”

Inputs required

  • Repo root and which theme is targeted (theme directory if multiple exist).
  • Target WordPress version range (theme.json version and features vary by core version).
  • Where the issue manifests: Site Editor, post editor, frontend, or all.

Procedure

0) Triage and locate block theme roots

  1. Run triage:
    • node skills/wp-project-triage/scripts/detect_wp_project.mjs
  2. Detect theme roots + key folders:
    • node skills/wp-block-themes/scripts/detect_block_themes.mjs

If multiple themes exist, pick one and scope all changes to that theme root.

1) Create a new block theme (if needed)

If you are creating a new block theme from scratch (or converting a classic theme):

  • Prefer starting from a known-good scaffold (or exporting from a WP environment) rather than guessing file layout.
  • Be explicit about the minimum supported WordPress version because theme.json schema versions differ.

Read:

  • references/creating-new-block-theme.md

After creating the theme root, re-run detect_block_themes and continue below.

2) Confirm theme type and override expectations

  • Block theme indicators:
    • theme.json present
    • templates/ and/or parts/ present
  • Remember the style hierarchy:
    • core defaults → theme.json → child theme → user customizations
    • user customizations can make theme.json edits appear “ignored”

Read:

  • references/debugging.md (style hierarchy + fastest checks)

3) Make theme.json changes safely

Decide whether you are changing:

  • settings (what the UI allows): presets, typography scale, colors, layout, spacing
  • styles (how it looks by default): CSS-like rules for elements/blocks

Read:

  • references/theme-json.md

4) Templates and template parts

  • Templates live under templates/ and are HTML.
  • Template parts live under parts/ and must not be nested in subdirectories.

Read:

  • references/templates-and-parts.md

5) Patterns

Prefer filesystem patterns under patterns/ when you want theme-owned patterns.

Read:

  • references/patterns.md

6) Style variations

Style variations are JSON files under styles/. Note: once a user picks a style variation, that selection is stored in the DB, so changing the file may not “update what the user sees” automatically.

Read:

  • references/style-variations.md

Verification

  • Site Editor reflects changes where expected (Styles UI, templates, patterns).
  • Frontend renders with expected styles.
  • If styles aren’t changing, confirm whether user customizations override theme defaults.
  • Run the repo’s build/lint scripts if assets are involved (fonts, custom JS/CSS build).

Failure modes / debugging

Start with:

  • references/debugging.md

Common issues:

  • wrong theme root (editing an inactive theme)
  • user customizations override your defaults
  • invalid theme.json shape/typos prevent application
  • templates/parts in wrong folders (or nested parts)

Escalation

If upstream behavior is unclear, consult canonical docs:

  • Theme Handbook and Block Editor Handbook for theme.json, templates, patterns, and style variations.

来自 wordpress 的更多技能

blueprint
wordpress
在创建、编辑或审查WordPress Playground蓝图JSON文件时使用。当提及蓝图、Playground配置或请求时触发…
official
wordpress-router
wordpress
对WordPress代码库进行分类,并根据插件、主题、区块及核心检出结果路由至正确的工作流程。运行自动化项目分类以识别仓库类型(插件、主题、区块主题、Gutenberg区块、WP核心)及可用工具。输出分类结果及基于用户意图和项目类型的决策树路由至领域特定技能。需要仓库根目录访问权限及bash/Node文件系统操作;部分工作流程需WP-CLI。目标环境为WordPress 6.9+及PHP 7.2.24+;...
official
wp-abilities-api
wordpress
WordPress Abilities API 注册、REST 暴露及客户端消费,适用于 WordPress 6.9+。使用 wp_register_ability() 和 wp_register_ability_category() 在 PHP 中注册能力和类别,包含稳定 ID、标签和元数据。通过设置 meta.show_in_rest: true,将能力暴露给客户端,使用 /wp-json/wp-abilities/v1/ REST 端点。在 JavaScript 中使用 @wordpress/abilities 包消费能力,实现客户端访问和权限检查。需要 WordPress 6.9+...
official
wp-abilities-audit
wordpress
审计WordPress插件的REST接口面,并生成一份标准化的审计文档,提出Abilities API注册建议。生成一份包含YAML……的markdown文档。
official
wp-abilities-verify
wordpress
验证WordPress插件的Abilities API注册:枚举能力,检查回调行为是否与每个注解的声明相符(对抗性…
official
wp-block-development
wordpress
WordPress区块开发(针对Gutenberg):元数据、注册、渲染及构建工作流。涵盖区块创建、block.json配置、静态与动态渲染,以及使用register_block_type_from_metadata()进行服务端PHP注册。强制使用apiVersion: 3以确保与WordPress 6.9+兼容,包括iframe编辑器支持和样式隔离。处理属性序列化、弃用/迁移以避免"无效区块"错误,以及内部区块组合。包括...
official
wp-interactivity-api
wordpress
在构建或调试WordPress Interactivity API功能时使用(data-wp-*指令、@wordpress/interactivity存储/状态/动作、块viewScriptModule…)
official
wp-patterns
wordpress
生成技术上正确、设计上独具特色的WordPress块模式。用于创建块模式、起始页面模式、模板模式、模板……
official