$100 Website Offer

Get your personal website + domain for just $100.

Limited Time Offer!

Claim Your Website Now

HTML code for WordPress Block Editor (Gutenberg) for API work laravel-wordpress-rest-api-client

Here’s a comprehensive list of commonly supported block names in the WordPress Block Editor (Gutenberg). Each block name is explained, along with its attributes and example code for usage in the Gutenberg Block Format.


Table of Supported Block Names

Block NameDescriptionCommon AttributesExample Use Case
core/paragraphAdds a text paragraph. Supports basic formatting like bold, italic, and links.align, placeholderText content with inline formatting.
core/headingAdds a heading block (H1-H6).level, align, placeholderSection headings.
core/listCreates ordered or unordered lists.ordered, alignBullet or numbered lists.
core/imageEmbeds an image with captions and alt text.url, align, alt, idAdding visual content.
core/quoteAdds a styled quote.value, citation, alignHighlighting key quotes.
core/galleryDisplays a grid of images.ids, columns, alignShowcasing photo collections.
core/videoEmbeds a video file.src, poster, alignAdding self-hosted videos.
core/audioEmbeds an audio file.src, align, autoplayPlaying audio clips.
core/codeDisplays preformatted code snippets.content, alignSharing code.
core/htmlAdds custom HTML content.NoneCustom HTML structures.
core/embedEmbeds external content like YouTube, Twitter.url, type, alignEmbedding social media or videos.
core/tableCreates a table with rows and columns.align, hasFixedLayoutOrganizing tabular data.
core/buttonAdds a styled button with a link.text, url, alignCall-to-action buttons.
core/separatorAdds a horizontal divider.align, classNameDividing sections.
core/spacerAdds adjustable vertical space.heightAdding spacing.
core/columnsCreates a column layout.columns, alignStructuring content into columns.
core/groupGroups multiple blocks together.align, classNameGrouping blocks for styling.

Examples for Each Block

1. Paragraph (core/paragraph)

[
    "blockName" => "core/paragraph",
    "attrs" => [],
    "innerHTML" => "<p>This is a sample paragraph with <strong>bold</strong> and <em>italic</em> text.</p>",
    "innerBlocks" => [],
    "innerContent" => [
        "<p>This is a sample paragraph with <strong>bold</strong> and <em>italic</em> text.</p>"
    ]
]

2. Heading (core/heading)

[
    "blockName" => "core/heading",
    "attrs" => ["level" => 2],
    "innerHTML" => "<h2>Sample Heading</h2>",
    "innerBlocks" => [],
    "innerContent" => [
        "<h2>Sample Heading</h2>"
    ]
]

3. List (core/list)

[
    "blockName" => "core/list",
    "attrs" => ["ordered" => false],
    "innerHTML" => "<ul><li>Item 1</li><li>Item 2</li></ul>",
    "innerBlocks" => [],
    "innerContent" => [
        "<ul><li>Item 1</li><li>Item 2</li></ul>"
    ]
]

4. Image (core/image)

[
    "blockName" => "core/image",
    "attrs" => ["url" => "https://example.com/image.jpg", "alt" => "Sample Image"],
    "innerHTML" => "<figure><img src='https://example.com/image.jpg' alt='Sample Image'/></figure>",
    "innerBlocks" => [],
    "innerContent" => [
        "<figure><img src='https://example.com/image.jpg' alt='Sample Image'/></figure>"
    ]
]

5. Quote (core/quote)

[
    "blockName" => "core/quote",
    "attrs" => [],
    "innerHTML" => "<blockquote><p>Inspirational quote goes here.</p><cite>Author Name</cite></blockquote>",
    "innerBlocks" => [],
    "innerContent" => [
        "<blockquote><p>Inspirational quote goes here.</p><cite>Author Name</cite></blockquote>"
    ]
]

6. Gallery (core/gallery)

[
    "blockName" => "core/gallery",
    "attrs" => ["ids" => [1, 2, 3], "columns" => 3],
    "innerHTML" => "<figure class='wp-block-gallery columns-3'>...</figure>",
    "innerBlocks" => [],
    "innerContent" => [
        "<figure class='wp-block-gallery columns-3'>...</figure>"
    ]
]

7. Button (core/button)

[
    "blockName" => "core/button",
    "attrs" => ["text" => "Click Me", "url" => "https://example.com"],
    "innerHTML" => "<a href='https://example.com' class='wp-block-button__link'>Click Me</a>",
    "innerBlocks" => [],
    "innerContent" => [
        "<a href='https://example.com' class='wp-block-button__link'>Click Me</a>"
    ]
]

How to Use This in Laravel

You can structure the content as a JSON-encoded array and pass it to the WordPress REST API when creating or updating posts. Here’s an example of how to send multiple blocks:

$content = [
    [
        "blockName" => "core/paragraph",
        "attrs" => [],
        "innerHTML" => "<p>This is a paragraph block.</p>",
        "innerBlocks" => [],
        "innerContent" => [
            "<p>This is a paragraph block.</p>"
        ]
    ],
    [
        "blockName" => "core/heading",
        "attrs" => ["level" => 2],
        "innerHTML" => "<h2>Heading Block</h2>",
        "innerBlocks" => [],
        "innerContent" => [
            "<h2>Heading Block</h2>"
        ]
    ]
];

// Pass $content as JSON to the API.
$data = [
    'title' => 'Post with Blocks',
    'content' => json_encode($content),
    'status' => 'publish'
];

Let me know if you’d like additional examples or a deeper explanation of any specific block!

Related Posts

The Ultimate Website Development Roadmap for Startups and Small Businesses

Introduction For startups and small businesses, a digital footprint is no longer a luxury—it is the foundation of market credibility. A business website serves as a 24/7…

Read More

Choosing a Reliable Website Development Partner for Sustainable Business Growth

Introduction In today’s hyper-connected economy, a company’s digital storefront is often its single most critical point of consumer interaction. A website is no longer just a digital…

Read More

WP-CLI Complete Tutorial: How to Install It, Understand It, and Use the Most Important wp Commands

If you manage WordPress sites regularly, WP-CLI can save a ridiculous amount of time. Instead of clicking through the dashboard for every plugin, theme, database, or user…

Read More

Master Troubleshooting Guide: Flarum Google Login OAuth Issue on cPanel/Apache with WordPress Root Site

1. Environment Overview This guide is based on a real troubleshooting case where: 2. Original Problem Google login was enabled for Flarum using FoF OAuth. The login…

Read More

Simplifying the Search for Trusted Professionals Near Me

Introduction We live in an era where you can manage almost your entire life from a smartphone, yet finding reliable local help often feels stuck in the…

Read More

Complete AIOps Training Guide: Tools, Use Cases, Certification & Career Path

Modern enterprise infrastructure generates far more data than human operators can realistically process. A typical cloud-native architecture experiences hundreds of thousands of ephemeral events daily, leading to…

Read More
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x