Skip to content

Instantly share code, notes, and snippets.

@tessak22
Created March 12, 2019 11:48
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 tessak22/ac8d10e44b2ba3da64c3abc970e72e0f to your computer and use it in GitHub Desktop.
Save tessak22/ac8d10e44b2ba3da64c3abc970e72e0f to your computer and use it in GitHub Desktop.
Building Gutenberg Blocks with ACF — Register Block
/**
* Register hero block
*/
add_action('acf/init', 'hero');
function hero() {
// check function exists
if( function_exists('acf_register_block') ) {
// register a hero block
acf_register_block(array(
'name' => 'hero',
'title' => __('Hero'),
'description' => __('Image background with text & call to action.'),
'render_callback' => 'hero_render_callback',
'category' => 'formatting',
'icon' => 'format-image',
'mode' => 'preview',
'keywords' => array( 'hero', 'image' ),
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment