Hello. I’m using this in an ACF child block to get a field value from the parent block:
// Get the context from the parent block
$fields = isset($context['acf/fields']) && is_array($context['acf/fields']) ? $context['acf/fields'] : [];
$sidebars = $fields['field_68a35548a985c'] ?? ($fields['sidebars'] ?? null);
I use $sidebars
to conditionally show or hide the sidebars (a template part) on my pages. It works fine in the site editor and the post editor, but is completely ignored on the front end.
I use !is_preview
and echo $context
to render the block on the front end unless $sidebars
is equal to no-sidebars, but it simply won’t work when $is_preview
is false. How do I get around this?
I also tried $sidebars = get_field('sidebars', get_the_ID());
but that didn’t work either.