Code

In this article


Display code snippets that respect your spacing and tabs.

  • Name: core/code
  • Category: text
  • API Version: 3
  • Block Type: Static (saved in post content)

Attributes

Defined via the attributes property in block.json.

Attribute Type Default Description
content rich-text Source: rich-text. Selector: code. Role: content

Supports

Defined via the supports property in block.json.

Block Markup

This is a static block. The markup is saved directly in the post content.

<!-- wp:core/code -->
<pre class="wp-block-code"><code>export default function MyButton() {
    return &lt;Button&gt;Click Me!&lt;/Button&gt;;
}</code></pre>
<!-- /wp:core/code -->

Source