Skip to main content

WordPress Gutenberg Custom Block Builder

Build custom Gutenberg blocks the right way: block.json attributes, an InspectorControls edit UI, InnerBlocks, ServerSideRender, transforms, and variations.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt builds a custom Gutenberg block named [block_name] for [block_purpose] the correct, modern way. It generates a block.json with [attributes], an Edit component exposing [controls] in InspectorControls, a properly serialized Save component, ServerSideRender for dynamic data from [data_source], block variations [variations], InnerBlocks for [inner_block_content], transforms from/to [transform_blocks], block styles [block_styles], a @wordpress/scripts build config, and PHP registration with a render callback — styled with [styling_approach].

The structure works because real Gutenberg blocks are React components with strict serialization rules, not shortcodes in disguise. Defining [attributes] in block.json first gives the editor and the saved markup a single contract. ServerSideRender handles dynamic content that can't be hardcoded, InnerBlocks makes [inner_block_content] flexible without breaking layout, and transforms let editors convert from [transform_blocks] they already use.

When to use it

  • You're building a real Gutenberg block, not faking one with a shortcode
  • You need editor controls for [controls] in InspectorControls
  • Your block renders dynamic content from [data_source] and needs ServerSideRender
  • You want flexible nested content via InnerBlocks for [inner_block_content]
  • You need [variations] and transforms from [transform_blocks] for editor convenience
  • You want a proper @wordpress/scripts build and an E2E test, not ad-hoc tooling

Example output

Expect a block package: a block.json declaring [attributes], an Edit component with [controls], a serialized Save component (or ServerSideRender for dynamic data from [data_source]), variation and transform definitions, InnerBlocks setup, block style registrations, a @wordpress/scripts build config, PHP registration with a render callback, and an E2E test using @wordpress/e2e-test-utils.

Pro tips

  • Define [attributes] carefully in block.json — they're the contract between Edit and Save, and mismatches cause block validation errors
  • Use ServerSideRender for anything truly dynamic from [data_source]; baking dynamic data into Save breaks on re-render
  • Keep [controls] minimal and grouped in InspectorControls so the editor stays usable
  • Add transforms from [transform_blocks] editors already use, like core/table, so migration into your block is one click
  • Match [styling_approach] to your theme tokens so the block inherits the site's design system
  • Run the generated E2E test — block validation issues often only surface when you actually edit and re-save in the editor

Frequently Asked Questions

Why not just build this as a shortcode instead?
Shortcodes don't integrate with the block editor's visual editing, controls, or transforms. A real Gutenberg block defined via `block.json` gives editors InspectorControls, variations, and InnerBlocks, producing a far better editing experience than a shortcode wrapped to look like a block.
When should the block use ServerSideRender versus Save?
Use ServerSideRender for genuinely dynamic content from `[data_source]` that changes after saving, like live data or queries. Use the Save component for static markup. Baking dynamic data into Save causes block validation errors when the content changes on re-render.
What causes block validation errors and how do I avoid them?
They usually come from a mismatch between the `[attributes]` declared in `block.json` and what the Save component outputs. Define attributes precisely, keep Save deterministic, and run the included E2E test, since these issues often only surface when editing and re-saving in the editor.
Can editors convert existing content into this block?
Yes, the prompt generates transforms from and to `[transform_blocks]` like core/table or core/columns. This lets editors convert blocks they already use into yours with one click, which smooths adoption and migration of existing content into the new block.
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