Loving the ACF Gutenberg Beta so far!
I am using a nested block approach to create a better grid for a boilerplate theme. I have created a block (via a plugin, the WP way – not ACF) called “Row” that will set an outer wrapper for other blocks (have added the
<InnerBlocks /> to this block). Using the
allowedBlocks parameter, I can specify all of the core blocks that are allowed in my “Row” block. This is all excellent so far…
As I create new ACF blocks, I don’t want to have to edit the plugin to add the ACF blocks to the plugin because the ACF blocks will differ between my projects. Gutenberg allows for a “parent” to be specified in a new block. This makes it so that the child block will be allowed in the parent block without specifically adding the new block to the list of
My question: is it possible to add a “parent” parameter to the
acf_register_block function? Similar to the other parameters like “name”, “title”, etc?
I realize this is similar to another topic already posted (link below), but not quite. I am creating the wrapper natively via a plugin. I’m just looking for the addition of a parent parameter.
I have made a change to the ACF plugin to accomplish this – perhaps I need to submit as a Git Issue/PR?
In any case – in
blocks.php in ACF, line 88
validate_block_type – I added an additional parameter to
$block array and was successfully able to pass it along via the
'parent' => ''
Are you able to share that plugin? I’d love to see it. I’m looking for a lightweight plugin with JUST a row/section/container/wrapper block, as you describe it, and I can’t find one!
@alicam unfortunately I’m not able to share the plugin at this time (it’s for my job).
The plugin, at the moment, is just a native Gutenberg block called “Row”. I created it following this tutorial for making a nested block. It’s essentially just a wrapper div with the
<InnerBlock> inside of it. Sorry I can’t be more helpful!
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🙋♂️ We are researching for our upcoming website redesign and would love to showcase some brands/agencies of popular or well known websites that use ACF.— Advanced Custom Fields (@wp_acf) October 11, 2019
If you have worked on, or know of any websites that would suit, please comment below.#WordPress
© 2019 Advanced Custom Fields. Subscribe