Skip to content

Instantly share code, notes, and snippets.

@kaelri
Last active January 29, 2021 17:27
Show Gist options
  • Select an option

  • Save kaelri/56f1b39c3cc49dd3ff4b9425608872ad to your computer and use it in GitHub Desktop.

Select an option

Save kaelri/56f1b39c3cc49dd3ff4b9425608872ad to your computer and use it in GitHub Desktop.
ACF Block with Inner Blocks Template
<?php
class myBlock {
public static function setup() {
add_action('acf/init', [ __CLASS__, 'register' ] );
}
public static function register() {
acf_register_block([
'name' => 'my-block',
'title' => __('My Block'),
'description' => __('A super cool block.'),
'render_callback' => [ __CLASS__, 'render' ],
'category' => 'my-category',
'icon' => 'images-alt2',
'keywords' => [ 'custom' ],
'supports' => [
'align' => true,
'mode' => false,
'jsx' => true
],
]);
}
public static function render( $block ) {
?><section class="my-block">
<div class="my-block-inner">
<InnerBlocks />
</div>
</section><?php
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment