Home › Forums › Front-end Issues › Extracting Relational data from repeater fields › Reply To: Extracting Relational data from repeater fields
I would do something like this with the original code I posted
<?php
if (get_field('event_session')) {
while (has_sub_field('event_session')) {
?>
<strong><?php the_sub_field('session_start'); ?></strong>
<?php the_sub_field('session_title'); ?><br />
<!-- Start of speaker list -->
<div class="speaker_list">
<?php
$sessionspeakers = get_sub_field('session_speaker');
if ($sessionspeakers) {
$count = 0;
echo 'Speaker';
if (count($sessionspeakers) > 1) {
echo 's';
}
echo ': ';
foreach ($sessionspeakers as $speaker) {
$count++;
$speakerlink = get_permalink($speaker->ID);
$speakerurltext = get_post_meta($speaker->ID, 'speakerurltext', true);
// if 'speakerurltext' is an acf field you could use
// $speakerurltext = get_field('speakerurltext', $speaker->ID);
if ($count > 1) {
echo ', ';
}
echo $speaker->post_title;
} // end foreach speakers
} // end if speakers
?>
</div>
<?php
} // end while has_sub_field
} // end if get_field
?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.