Support

Account

Home Forums Add-ons Repeater Field Repeater to create bootstrap tabs? Reply To: Repeater to create bootstrap tabs?

  • Thanks John.

    Incase anyone is interested here is my code…

    <?php 
    									$rows = get_field('tab_test');
    											echo '<pre>';
    												var_dump( $rows );
    											echo '</pre>';
    											
    											if (have_rows('tab_test')) {
    											
    											   echo'<ul class="nav nav-tabs" role="tablist">';
    											  
    											  while(have_rows('tab_test')) { the_row();
    											    
    											   $tab_button = get_sub_field('tab_button');
    											    $tab_id = get_sub_field('tab_id');
    											  
    											   
    											    echo' <li role="presentation"><a href="#'.$tab_id.'" aria-controls="'.$tab_button.'" role="tab" data-toggle="tab">';
    											    // output sub field content
    											    echo''.$tab_button.'';
    											    
    											    echo'</a></li>';
    											    
    											  }
    											  echo'</ul>';
    											  // reset the rows of the repeater
    											  reset_rows();
    											  echo'<div class="tab-content">';
    											  
    											  // second loop of same rows
    											  while(have_rows('tab_test')) { the_row();
    											  
    											  
    											     $tab_button = get_sub_field('tab_button');
    											    $tab_content = get_sub_field('tab_content');
    											    $tab_id = get_sub_field('tab_id');
    											    
    												    echo'<div role="tabpanel" class="tab-pane " id="'.$tab_id.'">';
    												  
    												    // output sub field content
    												    echo''. $tab_content.'';
    												    
    												    echo'</div>';
    											  }
    											  echo'</div>';
    											}
    									
    									 ?>