Skip to content

Instantly share code, notes, and snippets.

@digisavvy
Created October 29, 2018 05:42
Show Gist options
  • Select an option

  • Save digisavvy/ea1c652084fdc72b45101fa347720ccb to your computer and use it in GitHub Desktop.

Select an option

Save digisavvy/ea1c652084fdc72b45101fa347720ccb to your computer and use it in GitHub Desktop.
/**
* Render Gutenberg Block Template
*/
function my_acf_block_render_callback( $block ) {
// convert name ("acf/testimonial") into path friendly slug ("testimonial")
$slug = str_replace('acf/', '', $block['name']);
// include a template part from within the "template-parts/block" folder
if( file_exists(plugin_dir_path( __FILE__ ) . "/views/block-{$slug}.php") ) {
include( plugin_dir_path( __FILE__ ) . "/views/block-{$slug}.php" );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment