Skip to content

Instantly share code, notes, and snippets.

@gmmedia
Last active March 11, 2023 10:05
Show Gist options
  • Save gmmedia/4b7e754a0f81663c40bf84e157a511cc to your computer and use it in GitHub Desktop.
Save gmmedia/4b7e754a0f81663c40bf84e157a511cc to your computer and use it in GitHub Desktop.
WordPress: Wiederverwendbaren Block erstellen
<?php
function j0e_register_block_patterns() {
if ( class_exists( 'WP_Block_Patterns_Registry' ) ) {
register_block_pattern(
'j0e-header-pattern',
array(
'title' => __( 'Überschrift', 'j0e-patterns' ),
'description' => _x( 'Hier steht die Beschreibung des Pattern', 'Block pattern description', 'j0e-patterns' ),
'categories' => array('hero'),
'content' => "<!-- wp:heading -->
<h2>Überschrift 1</h2>
<!-- /wp:heading -->",
)
);
}
}
add_action( 'init', 'j0e_register_block_patterns' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment