Use when developing WordPress (Gutenberg) blocks: block.json metadata, register_block_type(_from_metadata), attributes/serialization, supports, dynamic rendering (render.php/render_callback), deprecations/migrations, viewScript vs viewScriptModule, and @wordpress/scripts/@wordpress/create-block build and test workflows.
설치
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
Use when developing WordPress (Gutenberg) blocks: block.json metadata, register_block_type(_from_metadata), attributes/serialization, supports, dynamic rendering (render.php/render_callback), deprecations/migrations, viewScript vs viewScriptModule, and @wordpress/scripts/@wordpress/create-block build and test workflows.
WP Block Development
Compatibility: Targets WordPress 6.9+ (PHP 7.2.24+). Filesystem-based agent with bash + node. Some workflows require WP-CLI.
Identify the block root (directory containing block.json) you’re changing.
If this repo is a full site (wp-content/ present), be explicit about which plugin/theme contains the block.
1) Create a new block (if needed)
If you are creating a new block, prefer scaffolding rather than hand-rolling structure:
Use @wordpress/create-block to scaffold a modern block/plugin setup.
If you need Interactivity API from day 1, use the interactive template.
Read:
references/creating-new-blocks.md
After scaffolding:
Re-run the block list script and confirm the new block root.
Continue with the remaining steps (model choice, metadata, registration, serialization).
2) Ensure apiVersion 3 (WordPress 6.9+)
WordPress 6.9 enforces apiVersion: 3 in the block.json schema. Blocks with apiVersion 2 or lower trigger console warnings when SCRIPT_DEBUG is enabled.
Why this matters:
WordPress 7.0 will run the post editor in an iframe regardless of block apiVersion.
apiVersion 3 ensures your block works correctly inside the iframed editor (style isolation, viewport units, media queries).
Migration: Changing from version 2 to 3 is usually as simple as updating the apiVersion field in block.json. However:
Test in a local environment with the iframe editor enabled.
Ensure any style handles are included in block.json (styles missing from the iframe won't apply).
Third-party scripts attached to a specific window may have scoping issues.
Read:
references/block-json.md (apiVersion and schema details)
3) Pick the right block model
Static block (markup saved into post content): implement save(); keep attributes serialization stable.
Dynamic block (server-rendered): use render in block.json (or render_callback in PHP) and keep save() minimal or null.
Interactive frontend behavior:
Prefer viewScriptModule for modern module-based view scripts where supported.
If you're working primarily on data-wp-* directives or stores, also use wp-interactivity-api.
4) Update block.json safely
Make changes in the block’s block.json, then confirm registration matches metadata.
For field-by-field guidance, read:
references/block-json.md
Common pitfalls:
changing name breaks compatibility (treat it as stable API)
changing saved markup without adding deprecated causes “Invalid block”
adding attributes without defining source/serialization correctly causes “attribute not saving”
5) Register the block (server-side preferred)
Prefer PHP registration using metadata, especially when:
you need dynamic rendering
you need translations (wp_set_script_translations)