Hi Emily @eatpaintchic,
You can display anything with this block with custom code. Here is the code to display both the featured image and excerpt from the related team member inside a seminar query loop:
add_filter( 'meta_field_block_get_acf_field', function ( $block_content, $post_id, $field, $raw_value ) {
$field_name = $field['name'] ?? '';
// Replace
team_member_image
with your unique name.
if ( 'team_member_image' === $field_name ) {
// Get post id for team member post.
$team_member_id = get_field( 'team_member', $post_id );
// Has a value.
if ( $team_member_id ) {
$block_content = get_the_post_thumbnail( $team_member_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 team_member_excerpt
with your unique name.
if ( 'team_member_excerpt' === $field_name ) {
// Get post id for team member post.
$team_member_id = get_field( 'team_member', $post_id );
// Has a value.
if ( $team_member_id ) {
$block_content = get_the_excerpt( $team_member_id );
}
}
return $block_content;
}, 10, 4);
In this snippet, I assume that you have an ACF field (Post Object) named team_member
in the seminar post to store the related team member. To display the featured image, you should add an instance of MFB and set the field name as team_member_image
. To display the excerpt, add another instance with the field name as team_member_excerpt
. Set the meta type for both instances as meta
. You don’t have to create a custom field for two fields team_member_image
and team_member_excerpt
. They are like dynamic fields created at runtime.
I’ve not tested it myself, but I believe it should work. Please let me know if it’s working and feel free to discuss if you need further help.
Regards, Phi.