Skip to content

Instantly share code, notes, and snippets.

@mharis

mharis/hooks.php

Last active Nov 16, 2018
Embed
What would you like to do?
<?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