I’ve a rpeater field that contain 4 sub_fields.
3 text sub field and 1 relationship field.
i can get the value for the text subfield but i can’t get value for relationship field. why?
<?php
// check if the repeater field has rows of data
if( have_rows('appuntamento') ):
// loop through the rows of data
while ( have_rows('appuntamento') ) : the_row();
?>
<p class="data"><?php the_sub_field('ora_appuntamento');?>, <?php the_sub_field('luogo_appuntamento');?>
<?php $posts = get_sub_field('autore_appuntamento');
if( $posts ): ?>
<?php foreach( $posts as $post_object): ?>
<a href="<?php echo get_permalink($post_object->ID); ?>"><?php echo get_the_title($post_object->ID); ?></a>
<?php endforeach; ?>
<?php endif;?>
<?php the_sub_field('descrizione_appuntamento');?>
<?php
endwhile;
else :
// no rows found
endif;
?>
Solved. i’ve replaced $posts with $myposts