Restrict Gutenberg Blocks to Single Use

For anyone who needs this too, here is how you restrict a block for single use only:

[php]// A Sample Block
acf_register_block(array(
‘name’ => ‘blockname’,
‘title’ => __(‘Block Name’,’slug’),
‘description’ => __(‘A translatable description’,’slug’),
‘render_callback’ => ‘theme_block_render’,
‘category’ => ’embed’, //the block category (optional)
‘align’ => ‘wide’, // default value for width
‘mode’ => ‘auto’, // default value for switching auomatically between edit and view mode
‘supports’ => array(‘align’ => array(‘wide’,’full’ ),’multiple’ => false), // wide and full are optional, those are for setting the width. SET MULTIPLE TO FALSE HERE!
‘icon’ => ‘welcome-view-site’, // Use a dashicon, for example dashicons-welcome-view-site
‘keywords’ => array( ‘blockname’, ‘image’,’text’ ), //set some keywords for search
)); [/php]

Further documentation can be found here: https://www.advancedcustomfields.com/resources/acf_register_block_type/

Leave a Comment