This snippet of PHP code is inside an Elementor template where I display posts from custom post type "proprieta" (English = property). I need to retrive details of the sales representative for that property. There are 2 ACF field group: one for "proprieta" and one for "venditore" (salesman). Inside the ACF field group for "proprieta" I added an object-field "venditori_proprieta" as to create a relation between the two field groups.
Now this is the code to display fields from the "venditore" field group:
$posts = get_posts(array(
'post_type' => 'venditore'
)
);
if( $posts ):
foreach( $posts as $post ): $venditore_id = get_field('venditore_proprieta');
$venditore_nome = get_field('nome_venditore', $venditore_id);
echo '<div class="foto">' . $venditore_nome . '</div>';
$venditore_photo = get_field('venditore_immagine', $venditore_id);
echo '<div class="foto">' . $venditore_photo . '</div>';
endforeach;
endif;
wp_reset_postdata(); ?>
still, nothing is displaying. Any hint? I'd appreciate your help.