Hello @eric7186, You do need to put a custom code in the functions.php file to make that work. Here is the code:
add_filter(
'meta_field_block_get_acf_field', function ( $block_content, $post_id, $field, $raw_value ) {
$field_name = $field['name'] ?? '';
// Replace location_street with your unique name.
if ('location_street' === $field_name ) {
// Get post id for location post.
$event_location_id = get_field('event_location', $post_id);
// Has a value.
if ($event_location_id ) {
$block_content = get_field('street', $event_location_id);
}
}
return $block_content;
}, 10, 4
);
add_filter(
'meta_field_block_get_acf_field', function ( $block_content, $post_id, $field, $raw_value ) {
$field_name = $field['name'] ?? '';
// Replace location_city with your unique name.
if ('location_city' === $field_name ) {
// Get post id for location post.
$event_location_id = get_field('event_location', $post_id);
// Has a value.
if ($event_location_id ) {
$block_content = get_field('city', $event_location_id);
}
}
return $block_content;
}, 10, 4
);
Because an event has only one location, I suggest you use a?Post Object field?for the event_location
field. The code above is for the Post Object field. To display the location street and city in the event, you use two MFB blocks and set the field type for both as ACF and the field name for them as location_street
and location_city
. Please let me know if it works. If you need further help, feel free to discuss more here.
Phi.