convert-to-wp-theme
Convert a complete HTML/CSS/JavaScript project into a production-ready WordPress block theme (Full Site Editing).
Convert a single HTML section or snippet into a registered WordPress block pattern PHP file.
> /plugin marketplace add siddik-web/wp-block-theme-converter > /plugin install wp-block-theme-converter@siddik-web
How it fires
How this command gets triggered: by you, by Claude, or both.
/wp-patternContext preview
What this command does when you run it.
Convert a single HTML section or snippet into a registered WordPress block pattern PHP file.
description: Convert a single HTML section or snippet into a registered WordPress block pattern PHP file.
**Purpose:** Convert a single HTML section/snippet into a registered WordPress block pattern PHP file.
User types `/wp-pattern` followed by HTML markup, OR pastes HTML and asks for a pattern.
From the HTML, infer:
| Pattern context | Block Types value | |-----------------|-------------------| | General page content (hero, CTA, features, etc.) | `core/post-content` | | Inside a Query Loop (post card, archive item) | `core/query` | | WooCommerce product grid item | `woocommerce/product-template` | | WooCommerce single product | `woocommerce/product-details` | | Header / navigation patterns | `core/template-part/header` | | Footer patterns | `core/template-part/footer` | | No specific insertion context (general-purpose) | Omit the line entirely |
Apply the conversion map from `references/block-conversion-map.md`. Key rules:
1. Wrap top-level in `<!-- wp:group {"layout":{"type":"constrained"}} -->` unless the section needs full-width 2. Convert each HTML element to its block equivalent (see map) 3. Replace hardcoded colors with `var(--wp--preset--color--{slug})` references 4. Replace hardcoded font sizes with preset references 5. Convert all user-facing strings to `<?php esc_html_e( 'string', 'text-domain' ); ?>` 6. Convert all asset paths to `<?php echo esc_url( get_template_directory_uri() ); ?>/assets/...` 7. NEVER include inline `<style>` or `<script>` tags 8. NEVER include inline `style=""` attributes — use block attributes instead
Use this exact structure (template at `templates/pattern-header.php.tpl`):
<?php
/**
* Title: {{Pattern Name}}
* Slug: {{theme-slug}}/{{pattern-slug}}
* Categories: {{category}}, featured
* Keywords: {{keyword1}}, {{keyword2}}, {{keyword3}}
* Viewport Width: 1400
* Block Types: {{BLOCK_TYPE}}
* Description: {{One-line description of the pattern}}
*/
?>
<!-- wp:group {"layout":{"type":"constrained"}} -->
<div class="wp-block-group">
<!-- converted block markup here -->
</div>
<!-- /wp:group -->Provide:
1. **The pattern file** in a single code block, labeled with its file path:
=== FILE: {{theme-slug}}/patterns/{{pattern-slug}}.php ===2. **Registration snippet** (if pattern category is custom) for `inc/block-patterns.php`:
register_block_pattern_category(
'{{theme-slug}}-{{category}}',
array( 'label' => __( '{{Category Label}}', '{{text-domain}}' ) )
);3. **CSS additions** (if any custom classes were used) for `assets/css/style.css`:
.wp-block-group.is-style-{{custom-style}} {
/* styles */
}AND mirror them in `assets/css/editor.css`.
4. **Usage note** — explain how the user can insert the pattern in Site Editor: > In Site Editor, click + → Patterns → search "{{Pattern Name}}" → click to insert.
If the HTML uses a clearly distinctive style (glassmorphism, brutalist, neon, etc.), suggest registering it as a block style variation:
This pattern has a distinctive **{{style-name}}** look. Consider registering it as a block style variation so users can apply the same look to other Group blocks:
Add to `inc/block-styles.php`:
\`\`\`php
register_block_style(
'core/group',
array(
'name' => '{{style-name}}',
'label' => __( '{{Style Label}}', '{{text-domain}}' ),
)
);
\`\`\`User: /wp-pattern <section class="hero"> <h1>Welcome to Acme</h1> <p>The best widgets in town.</p> <a href="/shop" class="btn-primary">Shop Now</a> </section>
→ Claude produces a complete `hero.php` pattern file with proper block markup, theme.json color references, and i18n strings.
A Claude Code plugin (and standalone skill) for converting any HTML/CSS/JavaScript project into a production-ready WordPress Block Theme (Full Site Editing). Author: Md Siddiqur Rahman License: MIT
Repo: siddik-web/wp-block-theme-converter
Convert a complete HTML/CSS/JavaScript project into a production-ready WordPress block theme (Full Site Editing).
Generate an empty, valid WordPress block theme scaffold from scratch — no source HTML required.
Scaffold a custom WordPress block (block.json, edit.js, save.js or render.php, styles) ready to register inside a block theme.
Convert an existing classic WordPress theme (PHP templates, functions.php) into a Full Site Editing block theme.
Diagnose and fix WordPress block-theme failures — block validation errors, theme.json issues, missing patterns, DB template overrides, and PHP warnings.
Migrate existing WordPress content (Classic Editor, ACF, widgets, CPTs, shortcodes, page builders) into a block theme.