Understanding blocks
“Block” is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage. The idea combines concepts of what in WordPress today we achieve with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience.Blocks replace the need for shortcodes, custom HTML, and widgets in WordPress, providing a unified content creation experience.
Block structure
Every block in WordPress consists of three main components:- Block metadata - Defined in
block.json, containing the block’s configuration - Edit component - The React component that renders the block in the editor
- Save function or render callback - How the block appears on the front end
Types of blocks
WordPress blocks can be categorized into several types:Text blocks
Paragraph, Heading, List, Quote, and other text-based content blocks.Media blocks
Image, Gallery, Video, Audio, and File blocks for embedding media content.Design blocks
Columns, Group, Separator, Spacer, and other layout and design elements.Widget blocks
Search, Archives, Categories, and other utility blocks.Theme blocks
Site Title, Navigation, Post Content, and other blocks for full-site editing.Embed blocks
YouTube, Twitter, and other third-party content embeds.Block composition
Blocks can contain other blocks, creating powerful nested structures:Block attributes
Blocks store data using attributes, which define the block’s content and settings:Block markup representation
Blocks are represented in the database using HTML comment delimiters:- The block name (
wp:paragraph) - The block attributes as JSON (
{"align":"center"}) - The static HTML content between the tags
Benefits of blocks
Consistency
Blocks provide a consistent editing experience across all content types
Flexibility
Each block can be individually customized and styled
Reusability
Blocks can be saved and reused across posts and pages
Extensibility
Developers can create custom blocks to extend WordPress functionality
Next steps
Block structure
Learn about the file structure of a block
Creating blocks
Start building your first custom block