
TL;DR — To create a custom Gutenberg block in 2026, pick one of three approaches: (1) use @wordpress/create-block scaffold for native React-based blocks (best for distributable plugins), (2) use ACF Blocks via Advanced Custom Fields Pro for PHP-rendered blocks (fastest for agency work, no JS knowledge needed), (3) use the Block Bindings API (WP 6.5+) to bind core blocks to custom data. All registered via block.json in 2026. Pick ACF Blocks if your team is PHP-focused, native React blocks if you need wide distribution or complex client-side interactivity.
Custom Gutenberg block — 5-step process
- Scaffold the block — run
npx @wordpress/create-block my-blockin your plugin directory. - Define the block in
block.json— name, title, category, icon, attributes, supports. - Write the Edit component — React component for the editor preview, with
useBlockProps()wrapper. - Write the Save function (or render.php for dynamic blocks) — what gets saved/rendered on the frontend.
- Register the block — call
register_block_type(__DIR__ . '/build');in your main plugin file.
Mastering Custom Gutenberg Blocks: A Comprehensive Guide
In the ever-evolving landscape of WordPress development, the Gutenberg block editor has revolutionized the way we create and manage content. While the block editor comes with a robust set of pre-built blocks, there are often instances where you need custom functionality that isn’t available out of the box. This guide will walk you through the process of creating custom Gutenberg blocks, covering both manual and plugin-based methods.
Why Create Custom Gutenberg Blocks?
Before diving into the technical aspects, it’s important to understand the benefits of creating custom Gutenberg blocks. Here are a few key reasons:
- Custom Functionality: Sometimes, the default blocks just don’t cut it. By creating custom blocks, you can add specific functionalities that are tailored to your needs or the needs of your clients.
- Reusability: Custom blocks can be reused across multiple pages and posts, saving you a significant amount of time in the long run.
- Flexibility: Custom blocks offer the flexibility to design and structure content in ways that aren’t possible with the default blocks.
Manual Creation of Custom Gutenberg Blocks
Creating custom Gutenberg blocks manually involves several steps, but it provides a deep understanding of how the Block API works.
Step 1: Create a Plugin to Enqueue Your Block Scripts & Styles
To start, you need to create a new plugin. Navigate to the wp-content/plugins directory of your WordPress installation via SFTP using a client like FileZilla. Create a new folder for your plugin, e.g., custom-block-plugin.
Inside this folder, create a plugin.php file and add the following code:
<?php
/*
Plugin Name: Custom Gutenberg Block
Description: A custom Gutenberg block plugin.
Version: 1.0
Author: Your Name
Author URI: https://yourwebsite.com
*/
function enqueue_block_editor_assets() {
wp_enqueue_script(
'custom-block-script',
plugins_url( 'block.js', __FILE__ ),
array( 'wp-blocks', 'wp-element' )
);
wp_enqueue_style(
'custom-block-style',
plugins_url( 'block.css', __FILE__ ),
array( 'wp-edit-blocks' )
);
}
add_action( 'enqueue_block_editor_assets', 'enqueue_block_editor_assets' );
This code enqueues the necessary JavaScript and CSS files for your block.
Step 2: Register the New Block Type
Next, create a block.js file in the same directory and add the following code:
import { registerBlockType } from '@wordpress/blocks';
import { RichText, InspectorControls, ColorPalette } from '@wordpress/block-editor';
import { Button } from '@wordpress/components';
registerBlockType('custom-block/custom-block', {
title: 'Custom Block',
icon: 'admin-users',
category: 'common',
attributes: {
content: { type: 'string' },
borderColor: { type: 'string' },
},
edit: EditComponent,
save: SaveComponent,
});
function EditComponent(props) {
const { attributes, setAttributes } = props;
const { content, borderColor } = attributes;
const onChangeContent = (newContent) => {
setAttributes({ content: newContent });
};
const onChangeBorderColor = (newBorderColor) => {
setAttributes({ borderColor: newBorderColor });
};
return (
<div>
<RichText
value={content}
onChange={onChangeContent}
placeholder="Enter your text here"
/>
<InspectorControls>
<ColorPalette
value={borderColor}
onChange={onChangeBorderColor}
/>
</InspectorControls>
</div>
);
}
function SaveComponent(props) {
const { attributes } = props;
const { content, borderColor } = attributes;
return (
<div style={{ border: `1px solid ${borderColor}` }}>
<RichText.Content value={content} />
</div>
);
}
This JavaScript code registers the block and defines its attributes and editing interface.
Using Plugins to Create Custom Gutenberg Blocks
While manual creation provides a deep understanding, using plugins can significantly simplify the process.
Block Lab Plugin
The Block Lab plugin allows you to create custom blocks directly from your WordPress dashboard without extensive coding.
- Install and activate the Block Lab plugin.
- Go to the
Custom Blockssection in your WordPress dashboard and clickAdd New. - Configure the block settings, such as name, category, icon, and fields.
- You can add various field types like text, numbers, email addresses, and more.
- Once configured, publish the block and it will be available in the block editor.
Genesis Custom Blocks Plugin
Another popular plugin is the Genesis Custom Blocks plugin, developed by the team behind WP Engine hosting.
- Install and activate the Genesis Custom Blocks plugin.
- Navigat to
Custom Blocks>Add Newin your WordPress dashboard. - Set up the block name, categories, and fields as needed.
- Create a block template using HTML, CSS, and optionally PHP.
- Upload the template files to your theme directory and start using the custom block.
Tools for Streamlining Block Development
For developers who prefer a more automated approach, there are tools like @wordpress/create-block and create-guten-block.
@wordpress/create-block
This is an official zero-configuration tool for creating Gutenberg blocks.
- Run the command
npx @wordpress/create-blockin your terminal to set up a new block plugin. - This tool generates all the necessary files and folders, including PHP, JS, and CSS code, to get you started quickly.
create-guten-block
This is a third-party development toolkit based on create-react-app.
- Run the command
npx create-guten-blockin your terminal to generate the plugin scaffolding. - This tool provides a preconfigured setup for React, webpack, ESLint, and more, making it easy to develop modern WordPress plugins.
Real-World Examples and Case Studies
Testimonials Block
A common use case for custom blocks is creating a testimonials block. Here’s how you can do it using the Genesis Custom Blocks plugin:
- Create a new block named “Testimonials” and add fields for the reviewer’s name, image, and testimonial text.
- Create a block template using HTML and CSS to style the testimonial output.
- Upload the template files to your theme directory and use the block in your posts or pages.
Custom Notice Block
Another example is a custom notice block that allows users to add arbitrary text input and display it in a notice box.
- Create a plugin to enqueue the block scripts and styles.
- Register the new block type using JavaScript and define its attributes and editing interface.
- Use the
edit()andsave()functions to handle the block’s backend and frontend rendering.
Best Practices and Hosting Considerations
When creating and using custom Gutenberg blocks, it’s crucial to follow best practices to ensure stability and performance.
- Testing Environment: Always test your custom blocks in a staging or local environment before deploying them to a live site. Tools like Local by WP Engine can be very helpful for this purpose.
- Hosting: Choose a reliable hosting provider that supports the latest versions of WordPress and PHP. Providers like Kinsta, known for their optimized WordPress hosting, can ensure your site runs smoothly with custom blocks.
Conclusion and Next Steps
Creating custom Gutenberg blocks can significantly enhance your WordPress site’s functionality and user experience. Whether you choose to go the manual route or use plugins and tools, the key is to understand the Block API and how to leverage it effectively.
If you’re looking for professional help in creating custom Gutenberg blocks or need assistance with any other WordPress development tasks, consider reaching out to Belov Digital Agency for expert solutions.
For more resources and tutorials on WordPress development, you can visit our blog at Belov Digital Agency Blog. If you have any questions or need further guidance, feel free to Contact Us.
By following these steps and best practices, you’ll be well on your way to mastering custom Gutenberg blocks and taking your WordPress site to the next level.
Need a senior WordPress team?
Belov Digital is a US WordPress agency with 12+ years and 2,600+ projects shipped. We work with US, Canadian, UK and Australian clients on retainers and project builds. See our WordPress services →
Follow-up questions we get on this topic
-
Should I use ACF Blocks or native React blocks?
ACF Blocks: faster to build, PHP-based, easier for client editing, no build step. Native React blocks: better client-side interactivity, more control over editor UX, fits modern WP. Rule of thumb: ACF for content-presentation blocks, native React for interactive widgets.
-
How do I make a block editable in InnerBlocks?
Use the `
` component (native React) or `` to limit what editors can drop in. For ACF Blocks, use the `InnerBlocks` field type added in ACF 6.x. Both require thinking about what nested-block structure makes sense — clients will absolutely use any flexibility you give them in unexpected ways. -
Can I use Tailwind CSS in a Gutenberg block?
Yes. Compile Tailwind CSS into your block’s stylesheet via @wordpress/scripts or your own build (Vite, Webpack). Use `useBlockProps()` to attach classes to the block wrapper. Caveat: Tailwind’s purge step needs to scan your block JSX so unused utility classes don’t get stripped.
-
How do I migrate from Classic Editor blocks (shortcodes) to Gutenberg?
For each shortcode, register an equivalent block (ACF Block or native). Then run a one-time migration script using WP-CLI: `wp post list –post_type=post –field=ID | xargs -I {} wp eval “…”` that converts `[shortcode]` instances to block markup. We have done this for 5K+ posts in single batches.
-
What’s the best way to share blocks across projects?
Package blocks as a small plugin instead of embedding them in your theme. That way you can reuse the same blocks across projects, version them independently, and avoid theme-coupled block code. We maintain an internal “BDA blocks” plugin that gets cherry-picked into each new client project.


