This seems to be a solution: https://wpfieldwork.com/pass-acf-fields-to-child-block/
Have not tried it yet.
Hi,
it did work via the old
acf_register_block_type
function and global php variables.
But with the new register_acf_blocks the global php variables seem not to work anymore.
I think this is because the php files are not “connected” anymore.
So f there is not wp trick something for this the only two solutions I can imagine are cookies or javascript.
@jhned: great piece of code! Thanks for sharing!
@johnnya23: I made a screenshot of the settings. You have to replace the field keys (“Schlüssel”). To see them go to configure view on the top right and activate field keys.
The select field is a Post-Object field which returns the id of the selected post. Multiple selection is active.
In my example the layouts field is called layout. So you have to replace “layouts” to “layout” here:
// Get the layouts value from the selected page.
$layouts_from_page = get_field_object( ‘layouts’, $page_id, false, true );
In Gutenberg you have to reload the page after saving to see the copied fields.
Hi John,
thanks your your reply!
It seems like the plugins are not the problem. I installed the same on my test system without issues.
Is it possible that there are some right issues when uploading the json file? Do you know to wich directory the json file is uploaded before the import?
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 use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.