To activate all the block supports for an ACF Block, you can use the following code:
add_action('acf/init', 'my_acf_init');
function my_acf_init() {
if( function_exists('acf_register_block') ) {
// register a new block
acf_register_block(array(
'name' => 'my-custom-block',
'title' => __('My Custom Block'),
'description' => __('A custom block.'),
'render_template' => 'path/to/template.php',
'category' => 'formatting',
'icon' => 'admin-comments',
'keywords' => array( 'custom', 'block' ),
'supports' => array(
'align' => array( 'left', 'center', 'right', 'wide', 'full' ),
'anchor' => true,
'html' => false,
'multiple' => true,
'reusable' => true,
'mode' => true,
),
));
}
}
In this example, we are registering a new block called my-custom-block
. We are setting various properties including the block's supports
array, which specifies the features that are supported by the block.
The supports
array includes the following options:
align
: Allows the block to be aligned left, center, right, wide, or full.anchor
: Allows the block to be given an anchor ID for linking to.html
: Allows the block to include custom HTML.multiple
: Allows multiple instances of the block to be added to the same post.reusable
: Allows the block to be saved as a reusable block.mode
: Allows the block to be used in both the block editor and the classic editor.By including all of these options in our supports
array, we are activating all of the block supports for our custom block.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-11-15 11:00:00 +0000
Seen: 8 times
Last updated: Apr 06 '23
How can a HTTP header be inserted in WordPress?
How can data be stored in a data attribute and utilized through Ajax?
How can an array be passed using typo3 flexform xml and itemsProcConfig?
Does JSON encode fail to retrieve data from the database?
Can the GS1 128 barcode decoder in PHP or Jquery be utilized?
How can Xdebug be used in conjunction with VSCode for Laravel on Sail and WSL2?
In PHP, what is the method for finding encrypted data using the "like" operator?
What is the method to pass a variable from PHP back to JavaScript?
Why do PHP variable variables display unexpected behavior when used with arrays?