Experience the powerful AI writing right inside WordPress
Show stunning before-and-after transformations with image sliders.
Improve user engagement by showing estimated reading time.
Written by saedul
Showcase Designs Using Before After Slider.
The WordPress Twenty Twenty-Three theme has taken the WordPress ecosystem by storm with its modern design and powerful block editor capabilities. Custom block development in this theme allows developers to extend its functionality and tailor content to specific needs. In this guide, we’ll delve into everything you need to know about WordPress Twenty Twenty-Three custom block development, offering insights and step-by-step instructions to help you master this essential skill.
The WordPress Twenty Twenty-Three theme is a block-based theme designed to leverage the full potential of the Gutenberg editor. It introduces a fresh approach to building websites with reusable blocks, enhanced design flexibility, and improved performance. The theme supports full site editing (FSE), making it easier than ever to customize layouts, templates, and blocks.
Custom blocks allow you to:
Before diving into custom block development, ensure you have the following:
To develop custom blocks, you’ll need:
@wordpress/scripts
npm install @wordpress/scripts --save-dev
Custom blocks are typically developed as plugins. Create a new folder in the wp-content/plugins directory, and add a PHP file to initialize your plugin. For example:
wp-content/plugins
<?php /* Plugin Name: Custom Blocks for Twenty Twenty-Three Description: A plugin for custom block development in the Twenty Twenty-Three theme. Version: 1.0 Author: Your Name */ // Register block assets. function register_custom_blocks() { wp_register_script( 'custom-blocks-script', plugins_url( 'build/index.js', __FILE__ ), [ 'wp-blocks', 'wp-element', 'wp-editor' ], filemtime( plugin_dir_path( __FILE__ ) . 'build/index.js' ) ); register_block_type( 'custom-blocks/example', [ 'editor_script' => 'custom-blocks-script', ]); } add_action( 'init', 'register_custom_blocks' );
Inside your plugin folder, create the following structure:
custom-blocks/ |-- src/ | |-- index.js |-- build/ |-- package.json |-- webpack.config.js
Edit src/index.js to define your block:
src/index.js
import { registerBlockType } from '@wordpress/blocks'; import { RichText } from '@wordpress/block-editor'; registerBlockType('custom-blocks/example', { title: 'Example Block', icon: 'smiley', category: 'common', attributes: { content: { type: 'string', source: 'html', selector: 'p', }, }, edit: ({ attributes, setAttributes }) => { const onChangeContent = (content) => setAttributes({ content }); return ( <RichText tagName="p" value={attributes.content} onChange={onChangeContent} /> ); }, save: ({ attributes }) => { return <RichText.Content tagName="p" value={attributes.content} />; }, });
Use the following command to build your block:
npx wp-scripts build
Activate your plugin from the WordPress dashboard to see your custom block in action.
Custom block development enhances the Twenty Twenty-Three theme’s capabilities by allowing developers to create unique content blocks tailored to specific design and functionality requirements.
Yes, you’ll need basic knowledge of JavaScript, React, and WordPress development to create custom blocks.
Yes, custom blocks are theme-independent. Once created, they can be used in any block-based WordPress theme.
Use browser developer tools, WordPress debugging plugins, and the console to identify and fix issues.
Custom block development offers better performance and control over design and functionality compared to many third-party plugins.
Mastering WordPress Twenty Twenty-Three custom block development opens up a world of possibilities for creating dynamic, personalized websites. By following this guide, you’ll be well-equipped to build and deploy custom blocks that enhance user experience and meet your unique needs. Start experimenting today and unlock the full potential of the Twenty Twenty-Three theme!
This page was last edited on 25 March 2025, at 10:57 am
Your email address will not be published. Required fields are marked *
Comment *
Name *
Email *
Website
Save my name, email, and website in this browser for the next time I comment.
How many people work in your company?Less than 1010-5050-250250+
By proceeding, you agree to our Privacy Policy