Support

Account

Home Forums ACF PRO Get Value of Sub-Field Outside of While Loop Reply To: Get Value of Sub-Field Outside of While Loop

  • I was able to figure it out. Never was able to get to the sub_field outside of the second nester so I put in a counter. In hindsight, it seems incredibly glaringly obvious but oh, well! Pasting for anyone else who might have the need. It might not be the smartest way to go about it but this did the trick for me:

     <?php 
    						
        if( have_rows('affiliations_&_links', 'option') ):
    
          while( have_rows('affiliations_&_links', 'option') ): the_row(); 
    					
        	if( have_rows('affiliations_repeater', 'option') ):
    				$x = 1;
    				echo '<ul>';	
    				while( have_rows('affiliations_repeater', 'option') ): the_row();
    						echo '<li>';
    						 // Flag for the first row
    						if ($x==1) :
              					echo '<h5>';
    						echo the_sub_field('link_type', 'option');
    						echo '</h5>';
           					else :  endif;
    						echo the_sub_field('al_name', 'option');
    						echo '</li>';
          			$x++; endwhile;  // ends affiliation repeater
    						echo '</ul>';
    		endif; // ends affiliation repeater
    	endwhile; // ends affiliation and links
    	endif;// ends affiliation and links
      ?>