All the custom blocks that I have created using AFC has stopped loading in the page editor. Essentially, the block just remains in a loading state and this makes saving the page impossible.
Here is the block code I am using:
/**
* Register Blocks Add Button
*/
add_action(‘acf/init’, ‘add_button_acf_init’);
function add_button_acf_init() {
// check function exists
if( function_exists(‘acf_register_block’) ) {
// register a testimonial block
acf_register_block(array(
‘name’ => ‘addbutton’,
‘title’ => __(‘Add Button’),
‘description’ => __(‘Add a single button’),
‘render_callback’ => ‘add_button_acf_block_render_callback’,
//’render_template’ => ‘template-parts/blocks/block-addbutton.php’, //tried this but it doesn’t work or I am missing additional steps
‘category’ => ‘layout’,
‘icon’ => ‘schedule’,
‘keywords’ => array( ‘button’),
));
}
}
function add_button_acf_block_render_callback( $block ) {
$slug = str_replace(‘acf/’, ”, $block[‘name’]);
// include a template part from within the “template-parts/block” folder
if( file_exists( plugin_dir_path( __FILE__ ) . ‘blocks/content-‘ . $slug . ‘.php’ ) ) {
include( plugin_dir_path( __FILE__ ) . ‘blocks/content-‘ . $slug . ‘.php’) ;
}
}