Ask any question about WordPress here... and get an instant response.
How can I create a custom block in the WordPress block editor?
Asked on Dec 19, 2025
Answer
Creating a custom block in the WordPress block editor involves using the Block API to define and register your block. This typically requires some knowledge of JavaScript and React, as the block editor is built on these technologies.
<!-- BEGIN COPY / PASTE -->
wp.blocks.registerBlockType('namespace/block-name', {
title: 'Custom Block',
icon: 'smiley',
category: 'common',
edit: function(props) {
return wp.element.createElement('p', {}, 'Hello, World!');
},
save: function(props) {
return wp.element.createElement('p', {}, 'Hello, World!');
}
});
<!-- END COPY / PASTE -->Additional Comment:
- Ensure you have a development environment set up with Node.js and npm to build your block.
- Use the "create-guten-block" toolkit to scaffold your block project if you're new to block development.
- Remember to enqueue your block's JavaScript and CSS files in your theme or plugin.
- Refer to the WordPress Block Editor Handbook for detailed guidance on block attributes and settings.
Recommended Links:
