$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

Building a Practical Roadmap for DevOps, SRE, and Platform Engineering

Introduction Navigating a career in modern software engineering often feels like trying to navigate a sprawling, ever-expanding maze. For aspiring engineers, developers, and IT professionals, the sheer…

Read More

How to Research and Compare Fertility Care Information Online

Introduction Researching reproductive health and family-building options on the internet can quickly become overwhelming. Anyone starting this journey faces an avalanche of unfamiliar clinical terminology, widely varying…

Read More

Architecting for Impact: The Executive Guide to High-Visibility Website Design

Introduction A company website serves as the primary anchor for its digital identity. Potential clients, partners, and job seekers visit a website to evaluate whether an organization…

Read More

The Smart Explorer’s Blueprint: Finding the Best of Hyderabad Online

Introduction: From Search to Local Experience A weekend outing or an evening plan rarely begins at the venue door. For most people, it starts with an open…

Read More

Student and Parent Guide to Finding Tutors, Coaching Institutes, and Degree Pathways

Introduction Education decisions in India shape long-term career opportunities, personal growth, and family investments. Every year, millions of school students manage board syllabus requirements, prepare for national…

Read More

The Executive Guide to Business Website Design: Uniting UX, SEO, and Brand Growth

Introduction A company website serves as the operational hub of its online presence. It represents the brand, delivers product and service information, answers buyer inquiries, and facilitates…

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