Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Yes—you can create a dynamic Gutenberg block without a JavaScript registration file. Register the block in PHP during init, set supports => array( 'autoRegister' => true ), and provide a render_callback (or a PHP template through block.json). WordPress stores the block comment and attributes, then generates the front-end HTML on the server whenever the post is rendered.

This approach is best for server-driven output, existing PHP templates, and data that must stay current. It is less suitable for blocks that need rich, highly interactive editing controls.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What a PHP-only Gutenberg block does

A PHP-only block is registered with WordPress on the server and rendered by PHP. There is no JavaScript file whose primary job is to call registerBlockType(). The block’s name, attributes, supports, and renderer are declared in PHP (or in a block.json file registered from PHP).

For a dynamic block, the editor does not need to save generated front-end markup. WordPress can save the block delimiter comment and its attributes, then invoke the server renderer each time the post is displayed. If a database value, template, or business rule changes, the output reflects that change without rewriting every post that contains the block.

#1 Best Overall
Sale
Compressed Air Duster,130000RPM Super Power Cordless Air Duster,Rechargeable Brushless Blower,3 Gear Adjustable Blower with LED Light,Dust Remover for Computer/House/Outdoor/Car
  • Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
  • With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
  • Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
  • Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
  • Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.

When this pattern is a good fit

  • Markup is primarily produced by PHP and changes with server-side data.
  • You already have a PHP template or rendering function that should be reused.
  • The editing interface can rely on core block controls and stored attributes rather than a custom React application.
  • You want a small plugin with no client-side build step for block registration.

When to choose a JavaScript-assisted block instead

Use a client-side editor implementation when authors need complex controls, immediate client-side previews, drag-and-drop interactions, or substantial editor-only behavior. Official WordPress guidance distinguishes faster client-side manipulation from server rendering that is valuable when existing PHP logic is central.

Create the plugin and register the block

Put the block in a plugin rather than a theme when it should remain available if the site changes themes. Create a directory such as wp-content/plugins/php-only-notice/ and add a main PHP file with a valid plugin header.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Create wp-content/plugins/php-only-notice/php-only-notice.php.
  2. Activate the plugin from Plugins in the WordPress administration area.
  3. Register the block from a function attached to init. Registration must happen before the editor or front end tries to use the block.

The following complete example registers a block named my-plugin/notice. The namespace should identify your plugin and the block name should be unique on the site.

<?php
/**
 * Plugin Name: PHP Only Notice Block
 */

function my_plugin_register_notice_block() {
    register_block_type(
        'my-plugin/notice',
        array(
            'api_version' => 3,
            'attributes' => array(
                'message' => array(
                    'type'    => 'string',
                    'default' => 'Hello from PHP',
                ),
            ),
            'supports' => array(
                'autoRegister' => true,
                'color' => array(
                    'background' => true,
                    'text' => true,
                ),
            ),
            'render_callback' => 'my_plugin_render_notice_block',
        )
    );
}
add_action( 'init', 'my_plugin_register_notice_block' );

function my_plugin_render_notice_block( $attributes, $content = '', $block = null ) {
    $message = isset( $attributes['message'] )
        ? $attributes['message']
        : 'Hello from PHP';

    $wrapper_attributes = get_block_wrapper_attributes();

    return sprintf(
        '<div %1$s>%2$s</div>',
        $wrapper_attributes,
        esc_html( $message )
    );
}

What each registration setting controls

  • api_version => 3 declares the block API version used by the registration.
  • attributes defines the data stored with each block instance. Here, message is a string with a default value.
  • supports.autoRegister tells WordPress that the block can be auto-registered for editor use from its server registration.
  • supports.color enables core text and background color support. These supports can add classes or inline styles to the wrapper.
  • render_callback names the PHP function that returns the block’s HTML.

register_block_type() returns a WP_Block_Type object when registration succeeds and false when it fails. During development, checking that return value or enabling WordPress debugging can expose a malformed name or registration array.

Write a safe render callback

The callback receives the block attributes, any saved inner content, and the current block instance. The callback must return the complete HTML string that should appear on the front end.

Escape values at output time

In the example, esc_html() converts the user-supplied message into text-safe HTML. Do not concatenate raw attribute values into markup. Choose an escaping function for the context: text nodes need HTML escaping, an attribute value needs attribute escaping, and a URL needs URL validation and escaping.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the standard wrapper helper

get_block_wrapper_attributes() produces the wrapper attributes expected by block supports and by WordPress’s block styling system. If you enable color, spacing, typography, or other supports later, calling this helper allows those features to contribute the appropriate classes and attributes.

Handle missing or older attributes

Posts can contain an older version of a block, or an attribute can be absent after a manual edit. Supply a fallback, as the example does for message, so rendering remains deterministic instead of generating notices or empty markup.

Keep callback responsibilities clear

Use the callback as the boundary between stored data and HTML. Read and validate the attributes first, obtain any server-side values your block needs, then build the wrapper and inner content. Returning one complete string makes the contract clear to WordPress and avoids accidental output from debugging statements or included files.

The $content argument contains saved inner block content when the block has inner blocks, while $block represents the current block instance. A simple notice may not need either argument, but accepting them keeps the callback signature compatible with dynamic block rendering and leaves room for later extensions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
EVEO® Screen Cleaner Spray Kit (Streak-Free) TV Screen Cleaner for Smart TV, Lcd, LEd, Oled | Computer Screen Cleaner Spray and Wipe Microfiber Cloth - TV, Monitor, Laptop, iPad, Car - 6.7oz 1 Pack
  • Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
  • Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
  • Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
  • Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
  • Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth

Use block.json when registration grows

A PHP array is convenient for a small block. A metadata file becomes easier to maintain when the block has several attributes, supports, styles, scripts, or a separate template. The render property points to a PHP file and is available from WordPress 6.1 onward.

Create a directory such as php-only-notice/notice/ inside the plugin and add this block.json:

{
  "apiVersion": 3,
  "name": "my-plugin/notice",
  "title": "PHP Notice",
  "category": "widgets",
  "attributes": {
    "message": {
      "type": "string",
      "default": "Hello from PHP"
    }
  },
  "supports": {
    "autoRegister": true,
    "color": {
      "background": true,
      "text": true
    }
  },
  "render": "file:./render.php"
}

Register the metadata directory from the plugin:

<?php
add_action( 'init', function () {
    register_block_type( __DIR__ . '/notice' );
} );

WordPress reads the metadata, registers the block, and uses the referenced template for dynamic output. The template receives $attributes, $content, and $block. Keep the template focused on producing markup and escape values before printing them.

<?php
$message = isset( $attributes['message'] )
    ? $attributes['message']
    : 'Hello from PHP';

$wrapper_attributes = get_block_wrapper_attributes();
?>
<div <?php echo $wrapper_attributes; ?>>
    <?php echo esc_html( $message ); ?>
</div>

Do not register both the array version and the metadata version under the same name. Choose one source of truth, or WordPress may report a duplicate or conflicting registration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a layout that is easy to debug

A practical metadata-based plugin can contain a main loader, a block directory, block.json, and render.php:

php-only-notice/
├── php-only-notice.php
└── notice/
    ├── block.json
    └── render.php

The loader should do little more than attach registration to init. Keep presentation in render.php and avoid placing plugin bootstrapping, database queries, and large amounts of markup in the metadata file. This separation makes it obvious which file to inspect when a block fails to register and which file controls front-end output.

Understand dynamic rendering and saved content

A dynamic block separates persisted data from generated presentation. The post content stores the block comment and serialized attributes; the renderer creates the HTML when WordPress renders the post. This is useful for notices, query-driven lists, account information, or any output whose source data can change after publication.

Why a null save result matters

In a conventional JavaScript block, a save function returns markup that is written into post content. A dynamic block uses a null save result, so WordPress does not treat generated HTML as the canonical saved representation. The server callback becomes the canonical renderer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Because only the delimiter and attributes are persisted, changing the PHP template or the value returned by a server query changes the next rendered response. You do not have to open and resave every post containing the block merely to refresh generated markup. The trade-off is that the callback must remain available whenever WordPress renders the post.

Trade-offs versus static markup

Static blocks can be simpler for fixed content because the generated markup is stored with the post. However, changing the saved markup or its structure can trigger block validation problems in existing posts. Dynamic rendering avoids stale generated HTML, but every front-end render depends on the PHP callback and any data it reads.

Rank #3
BladeHawks RGB Gaming Mouse Pad Extra Large Extended 31.5x12 Inch-Black
  • 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
  • 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
  • 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
  • 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
  • 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.

Do not switch an established block casually between static and dynamic behavior. Existing posts may contain saved markup produced under the earlier model, and changing the block name, attribute schema, or save behavior can make those instances appear invalid. Preserve the name and supply sensible defaults while you decide how to migrate older content.

Editor behavior and live previews

Auto-registered PHP blocks are intended for server-rendered output and do not require a JavaScript block registration file. Authors can insert the block and edit registered attributes through the editor, but the editing experience is not equivalent to a fully custom React-based interface.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If an existing PHP renderer needs a live server preview in the editor, the @wordpress/server-side-render component requests the callback through /wp/v2/block-renderer/:block. The block and its attributes must already be registered in PHP for that endpoint to render anything.

That preview route does not replace registration. It is a way for a client-side editor component to ask WordPress for the same server-generated markup. If the endpoint returns nothing, first verify the PHP registration, block name, and attribute payload before investigating editor code.

Plan the attribute model around editing needs

  • Use simple scalar attributes for values authors edit directly, such as a message or an identifier.
  • Give each attribute a type and, where appropriate, a default so older instances remain renderable.
  • Keep server-only state out of serialized attributes when it can be derived safely at render time.
  • Expect complex interactions, conditional controls, and rich previews to require client-side code.

Every attribute is part of the block’s persistence contract. Renaming message, changing its type, or removing its default affects existing serialized comments. If an attribute is optional, make the callback tolerate its absence. If it is required for useful output, define a safe fallback rather than emitting an undefined-index notice.

PHP-only versus conventional server-and-client registration

Axis PHP-only auto-registered block Conventional server + client registration
JavaScript required for registration No Usually yes for editor settings
Rendering Server-side callback or PHP template Static save or server-side callback
Best fit Server-driven, low-interactivity output Rich editor controls and interactive previews
Data freshness Generated at render time Depends on static or dynamic design
Supports integration Available through server registration Available when registered on the server

The choice is about where rendering and interaction belong, not about whether PHP is allowed in Gutenberg. A client-side editor can still use a server-rendered front end; a PHP-only block simply keeps registration and rendering logic on the server.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Questions to ask before choosing

  1. Can the author work with core controls and a few stored values, or does the block need a custom interface?
  2. Should output reflect changing server data immediately, or should the published post preserve a snapshot?
  3. Is an existing PHP template the authoritative presentation that should be reused?
  4. Will the block need editor-only interactions that cannot be expressed through server registration and core supports?

If the answers emphasize server data, reusable PHP, and modest controls, auto-registration is a natural fit. If they emphasize complex editor behavior and immediate manipulation, plan for a JavaScript-assisted editor while retaining PHP for front-end rendering if that is useful.

Test the block before deploying it

  1. Activate the plugin and confirm that the block appears under the category declared in the registration or metadata.
  2. Insert the block, leave the default message unchanged, and save the post.
  3. Edit the message with characters such as <, >, and quotation marks. View the front end and verify that they display as text rather than becoming markup.
  4. Change the block’s text and background colors if those supports are enabled. Inspect the wrapper and confirm that the generated classes or styles are present.
  5. Update the default or renderer output in PHP, reload a post containing the block, and verify that dynamic output changes without manually editing the post content.
  6. Test an older or hand-edited block comment with the message attribute omitted. The fallback should render without a PHP notice.

Test both the editor and the public response. A block can be correctly registered yet fail on the front end because the callback is not callable, while a callback can render correctly for visitors but be absent from the editor because the registration hook never ran in that request. Testing with caches bypassed also helps distinguish PHP changes from stale HTML.

Troubleshooting common failures

The block does not appear in the inserter

  • Confirm the plugin is active and the registration function is attached to init.
  • Check that the block name contains a namespace and a block slug separated by a slash, such as my-plugin/notice.
  • Make sure the metadata path points to the directory that actually contains block.json.
  • Look for a PHP parse error or an invalid JSON property; either can prevent registration.

The front end shows an empty area or no markup

  • Verify that render_callback names a callable function and that the function returns a string.
  • Check that the callback is declared before registration is used, or that the file containing it is loaded by the plugin.
  • Inspect the attribute key and type. A mismatch between the saved key and the callback’s lookup can produce an empty value.
  • If using render.php, verify the file path uses the file:./render.php form in metadata and that the file exists beside block.json.

Color or other supports do not work

Declare the support in the server registration or block.json, then output get_block_wrapper_attributes() on the element that should receive those styles. Hard-coding a replacement wrapper without the helper prevents WordPress from adding registered support attributes.

Changes seem stuck after an edit

Clear page, object, or reverse-proxy caches that may be serving an older response, then reload the post while logged out. Dynamic rendering updates PHP output at render time, but an external cache can still retain a previous HTML response.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Vaydeer Wrist Rest for Keyboard and Mouse, Computer Ergonomic Wrist Support Pad, Soft Memory Foam Arm Cushion for Desk, Palm Hand Office Laptop Typing
  • 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
  • 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
  • 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
  • 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
  • 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.

Existing posts report validation errors

Check whether the block was changed from static saved markup to dynamic rendering, or whether its name and attribute definitions changed. Preserve the original block name and maintain sensible defaults for attributes already stored in posts. If the saved structure was intentionally changed, migrate existing content deliberately rather than silently changing the schema.

The editor preview differs from the front end

Compare the attributes sent to the server with the attributes stored in the post and make sure both paths use the same registration. If a server-side preview is implemented with @wordpress/server-side-render, confirm that the block-renderer endpoint can resolve the PHP registration. Differences often come from an attribute default, a missing wrapper helper, or a template that assumes a value is always present.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Practical design and maintenance guidance

Keep names stable

The block name is part of the serialized comment in post content. Treat the namespace and slug as a compatibility identifier: changing them makes existing instances appear to be unknown blocks unless you provide a migration strategy.

Keep rendering deterministic

Given the same attributes and server data, the callback should produce predictable markup. Avoid notices, undefined indexes, and conditional output that depends on an unvalidated value. Deterministic output makes editor previews and front-end debugging easier.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Separate data retrieval from presentation

Fetch or calculate server data in a focused function, then pass the resulting values into the template or output section. This keeps escaping visible at the point where values enter HTML and makes later changes less likely to introduce unsafe concatenation.

Document the attribute contract

Record each attribute’s type, default, and expected range in code comments or plugin documentation. This is especially important when several templates or future versions of the block consume the same attributes.

Keep one registration source

Use either the PHP array or the metadata directory for a given block name. Duplicating registration makes it unclear which attributes and supports WordPress should use and can lead to duplicate-registration errors. When moving from an array to block.json, keep the name and attribute definitions equivalent, test existing posts, and remove the old registration path.

Review changes as schema changes

Adding an optional attribute with a default is generally easier for existing content than deleting or renaming one. Before changing a type or removing a support, inspect representative posts and decide how older serialized attributes should be interpreted. A deliberate migration is safer than relying on a renderer to guess what an old value meant.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently asked questions

How do I create a Gutenberg block with PHP only?

Register a unique block name during init, define its attributes and supports, set autoRegister to true, and provide a render_callback. Return escaped HTML from the callback. For a larger block, put the same metadata in block.json and register its directory from PHP.

Can I make a dynamic block without JavaScript?

Yes. A PHP-registered dynamic block can save its delimiter and attributes while generating front-end markup through PHP. The editor experience is limited compared with a custom JavaScript interface, so this pattern is best when output is server-driven and interaction is modest.

Best Value
Sale
Under Desk Cable Management Tray No Drill, Metal Mesh Cable Management Under Desk with Clamp Mount, 2 Hole Cable Tray with Wire Management and Cord Organizer for Home Office Standing Desk
  • 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
  • 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
  • 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
  • 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
  • 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.

What does supports.autoRegister do?

It tells WordPress that the server-registered block can be auto-registered for editor use. It does not replace the PHP registration, attributes, or renderer; those still need to be valid when WordPress runs the init hook.

When should I use block.json instead of a PHP array?

Use a metadata file when the block has several attributes, supports, styles, scripts, or a separate PHP template. Its render property can point to render.php beginning with WordPress 6.1. A short PHP array remains practical for a small block.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why is my callback not running?

Check that the registration function is attached to init, the callback name is callable, and the plugin file defining the callback is loaded. With metadata, confirm that render.php exists beside block.json and uses the file:./render.php reference.

How do I get a live server preview in the editor?

The @wordpress/server-side-render component can request the registered callback through /wp/v2/block-renderer/:block. The block and its attributes must be registered in PHP first. This adds a server preview but does not provide the rich editing controls of a custom client-side implementation.

Bottom line

To create a Gutenberg block with PHP only, register it during init, define its attributes and supports, enable autoRegister, and return escaped markup from a render_callback or PHP template. Use this pattern for low-interactivity, server-driven blocks whose output should stay current. Choose a JavaScript-assisted editor when authors need rich interactive controls or substantial client-side behavior.

Frequently Asked Questions

How do I create a Gutenberg block with PHP only?

Register a unique block during init, define its attributes and supports, enable supports.autoRegister, and return escaped HTML from a render_callback. For larger blocks, register a block.json directory and use its PHP render.php template.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I make a dynamic block without JavaScript?

Yes. A PHP-registered dynamic block stores its delimiter and attributes while PHP generates the front-end markup. This works best for server-driven output with modest editing needs.

What does supports.autoRegister do?

It allows a block registered on the server to be auto-registered for editor use. The PHP registration, attributes, and renderer must still be valid.

When should I use block.json?

Use block.json when the block has multiple attributes, supports, styles, scripts, or a separate PHP template. The render property can reference render.php in WordPress 6.1 and later.

Why is my render callback not running?

Verify the init hook, callback name, plugin loading order, block name, and metadata path. For a template, confirm render.php exists beside block.json and uses file:./render.php.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can the editor show a live PHP-rendered preview?

Yes. @wordpress/server-side-render can call /wp/v2/block-renderer/:block, provided the block and its attributes are registered in PHP.

The Bottom Line

Use PHP-only Gutenberg blocks when the server should own registration and rendering. Register on init, enable autoRegister, escape every output value, and keep attributes stable. Move to a JavaScript-assisted editor when rich interaction—not server-driven markup—is the primary requirement.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.