Support

Account

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.