Skip to content

Instantly share code, notes, and snippets.

@mharis
Last active November 16, 2018 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mharis/e1f4ce59ff0d6839fdd328a41f19189c to your computer and use it in GitHub Desktop.
Save mharis/e1f4ce59ff0d6839fdd328a41f19189c to your computer and use it in GitHub Desktop.
<?php
/**
* Adds Gutenberg Blocks with ACF.
*
* @return void
*/
function wds_register_acf_gutenberg_blocks() {
if ( function_exists( 'acf_register_block' ) ) {
// Register the hero block.
acf_register_block(array(
'name' => 'hero',
'title' => __( 'Hero', 'wds' ),
'description' => __( 'A hero block.', 'wds' ),
'render_template' => get_template_directory() . '/template-parts/gutenberg/hero.php',
'category' => 'layout',
'icon' => 'slides',
'mode' => 'preview',
'keywords' => array( 'hero', 'slider' ),
));
}
}
add_action( 'acf/init', 'wds_register_acf_gutenberg_blocks' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment