Support

Account

Home Forums Add-ons Repeater Field Repeater Issue

Solved

Repeater Issue

  • I am using bootstrap tab:

    <ul class="nav nav-tabs" role="tablist">
      <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
      <?php if( get_field('repeater', 'option') ): ?>
    	<?php while( has_sub_field('repeater_subfield1', 'option') ): ?>
            <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Profile</a></li>
        <?php break; endwhile; ?>
      <?php endif;  ?>
    </ul>
    
    <!-- Tab panes -->
    <div class="tab-content">
      <div role="tabpanel" class="tab-pane active" id="home">Home Text</div>
      <div role="tabpanel" class="tab-pane" id="profile">
        <?php  while ( have_rows('repeater', 'option') ) : the_row(); ?>
        <div class="col-sm-2 col-xs-6 color_showcase text-center"> 
        	<img src="<?php the_sub_field('repeater_subfield1'); ?>" alt=""> 
          	<?php the_sub_field('repeater_subfield2'); ?>
        </div>
        <?php endwhile;  ?>
        </div>
    </div>

    If Repeater sub fields are empty then there is no meaning of showing Profile Tab. All works well but if you have like 10 repeat fields, only 9 shows in tab content and 1 is already echoed by the first get_field code.

    Am I clear ?

  • Hi @debendra

    Sorry but you need to elaborate a bit ..
    Where’s the issue? Or is it that you’re tying to do something but not succeeding?

    Also, you’re using old repeater code for the first part with has_sub_fields but then correct code in the second while loop. Why?

  • Hi Jonathan

    I used old code for trying only, my problem is:

    inside tab panel there are repeater subfields, if there are subfields it is fine to show the <li> tab but if no repeater subfields then I don’t need to show this <li> tab. (did you get me?).

    I am doing everything fine, but I am not able to echo all repeater fields in tab-pane, the first one will be missing, the first one will be echoed on first condition in <li>

    If you are not clear, I can send you wp-admin user and pass as well personally in your email.

  • Hi Jonathan
    I have solved this, I am loving this ACF.

    <ul class="nav nav-tabs" role="tablist">
      <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
      <?php if ( have_rows('repeater', 'option') ) {
    	while ( have_rows('repeater', 'option') ) : the_row(); 
    	$image = get_sub_field('repeater_subfield1', 'option' );
    	endwhile; 
    	if($image) {
    	?>
    	<li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Profile</a></li>
    	<?php }  } ?>
      </ul>
    
    <!-- Tab panes -->
    <div class="tab-content">
      <div role="tabpanel" class="tab-pane active" id="home">Home Text</div>
      <div role="tabpanel" class="tab-pane" id="profile">
        <?php  while ( have_rows('repeater', 'option') ) : the_row(); ?>
        <div class="col-sm-2 col-xs-6 color_showcase text-center"> 
        	<img src="<?php the_sub_field('repeater_subfield1'); ?>" alt=""> 
          	<?php the_sub_field('repeater_subfield2'); ?>
        </div>
        <?php endwhile;  ?>
        </div>
    </div>
  • Hi @debendra

    Great to hear!
    The code looks solid. I also have a fondness for ACF 😉

    Best of luck with your coding

  • It is very important that the repeater itself achieves the best possible coverage from the router where it is located. If your repeater has insufficient coverage, it can actively help make your entire Wi-Fi network worse.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.