Home › Forums › Front-end Issues › Extracting Relational data from repeater fields › Reply To: Extracting Relational data from repeater fields
John, you’ve been a great help. Just one last question and i believe this is done. how would i make it so that if there is more than 1 speaker it says “speakers” instead of just “speaker”? Can i count the array before the foreach?
I tried inserting this:
...
$sessionspeakers = get_sub_field('session_speaker');
if ($sessionspeakers) {
$count = 0;
if($post_count=1){
echo 'Speaker '.$post_count.':<br>';
} else {
echo 'Speakers '.$post_count.':<br>';
}
foreach ($sessionspeakers as $speaker) {
...
but it only returns 1 no matter how many speakers there are.
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.