I am trying to to get the values from custom fields from an ACF Block on a subpage.
I have been partially successful. The ACF Block is named acf/website-overview. The block contains a field called overview, which I can successfully get to show. It’s a WYSIWYG field.
The two other fields are subfields of a group field called meta. The subfields are named expertise (checkbox field) and website_address (url).
I’m starting to pull my hair out. Does anyone know what I might need to add to my code?
<?php
$post_id = $page->ID;
$post = get_post($post_id);
$blocks = parse_blocks($post->post_content);
foreach ($blocks as $block) {
if ($block['blockName'] == 'acf/website-overview') {
$overview = $blocks[0]['attrs']['data']['overview'];
$skills = $blocks[0]['attrs']['data']['expertise'];
$websiteAddress = $blocks[0]['attrs']['data']['website_address'];
}
}
?>
<?php echo '<p>' . substr_replace($overview, "…", $excerpt_length) . '</p>'; ?>
<?php echo $skills ; ?>
<?php echo $websiteAddress ; ?>
Hi, where you able to figure this out? Having the same problem. Thanks!