Skip to main content

Claude/ChatGPT Prompt to Build a Gutenberg Block with React

Build a custom Gutenberg block in React with attributes, dynamic PHP render, InspectorControls, transforms, and block patterns.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt makes the AI a senior WordPress engineer that builds a custom Gutenberg block and returns working plugin code, not pseudocode. You provide the [block_name], the [attributes], and the [render_mode], with tooling fixed to @wordpress/scripts using block.json and JSX, and it returns the full file tree followed by each key file - PHP bootstrap, block.json, edit.js, and render.php - in its own code block.

The six deliverables produce a clean, installable block: a block.json declaring your [attributes], supports, and the render callback; a React-based editor UI in edit.js with a live preview of the attributes; a dynamic server-side render in PHP that outputs the saved attributes via your [render_mode]; InspectorControls in the sidebar for every editable setting; block transforms to and from a core block plus at least one registered block pattern; and the plugin bootstrap file and folder structure so it installs cleanly. The structure works because custom blocks are where you escape page-builder bloat, and dynamic server render keeps data-driven content from shipping as stale static HTML.

When to use it

  • You want a custom Gutenberg block instead of page-builder bloat.
  • Your block is data-driven - pricing, listings - and must render fresh on the server.
  • You need a React editor UI with live preview and sidebar InspectorControls.
  • You want block transforms to and from a core block plus a registered pattern.
  • You need a clean plugin bootstrap and folder structure that installs without fuss.

Example output

You get the full file tree, then each key file in its own block: the PHP bootstrap that registers the plugin, a block.json declaring your [attributes], supports, and render callback, an edit.js React editor UI with live preview and InspectorControls for every setting, and a render.php that outputs the saved attributes via your [render_mode] - plus block transforms and at least one registered pattern.

Pro tips

  • Choose dynamic server-side render for anything data-driven like pricing or listings, so editors never ship stale static HTML.
  • Define [attributes] precisely - their types in block.json drive both the editor controls and what render.php receives.
  • Keep InspectorControls covering every editable setting so editors do not have to touch markup.
  • Set [block_name] to a clear, namespaced value so it does not collide with core or other plugin blocks.
  • Use the block transforms to let editors convert from a core block, smoothing migration off existing content.
  • Match the [render_mode] to the data: static render is fine for fixed content, but dynamic is essential when the output changes.
  • Register at least one block pattern so editors start from a sensible default layout instead of an empty block they have to configure from scratch.
  • Build with @wordpress/scripts as specified rather than hand-rolling the bundler, so block.json and the JSX editor build stay aligned with current WordPress conventions.

Frequently Asked Questions

When should I use dynamic server-side render instead of static?
Use dynamic render for anything data-driven such as pricing tables or listings, so the block outputs current data on every page load. Static render saves HTML at edit time, which means data-driven content can ship stale - dynamic render avoids that entirely.
Does this build a real plugin or just block files?
It returns a complete, installable plugin - the PHP bootstrap, block.json, edit.js, render.php, and folder structure - using @wordpress/scripts. You still run the build step and activate the plugin, but the files are meant to install cleanly as delivered.
What do InspectorControls and block transforms add?
InspectorControls put every editable setting in the sidebar so editors configure the block without touching markup. Block transforms let editors convert to and from a core block, which smooths migrating existing content into your custom block.
How do the block attributes connect the editor and the server render?
The `[attributes]` declared in block.json define the data the editor UI edits and the values render.php receives at output time. Getting their types right is what keeps the live editor preview and the server-rendered output consistent.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in WordPress & CMS Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support