I am using the advanced custom fields plugin. I have two repeater fields to output, at present my code only displays the first repeater field. How can I display the 2nd with my code, please?
<div class="container">
<?php
// check if the repeater field has rows of data
if( have_rows('single_programme_details') ): $prog_wom = 0;
// loop through the rows of data
while ( have_rows('single_programme_details') ) : the_row(); $prog_wom++ ;
if ($prog_wom % 2 == 0) { ?>
<div class="row">
<div class="col-md-6">
<?php $prog_womanity_section_single_image = get_sub_field('image_for_the_programme_section_single'); ?>
<img src="<?php echo $prog_womanity_section_single_image['url']; ?>" alt="<?php echo $prog_womanity_section_single_image['alt']; ?>">
</div>
<div class="col-md-6">
<?php the_sub_field('title_of_programme_section_single'); ?>
<?php the_sub_field('text_area_for_programme_section'); ?>
</div>
</div>
<?php } else { ?>
<div class="row">
<div class="col-md-6">
<?php the_sub_field('title_of_programme_section_single'); ?>
<?php the_sub_field('text_area_for_programme_section'); ?>
</div>
<div class="col-md-6">
<?php $prog_womanity_section_single_image = get_sub_field('image_for_the_programme_section_single'); ?>
<img src="<?php echo $prog_womanity_section_single_image['url']; ?>" alt="<?php echo $prog_womanity_section_single_image['alt']; ?>">
</div>
</div>
<?php }
endwhile;
endif;
reset_rows();
?>
</div> <!-- close container -->
<!-- repeating information sections - one per row END -->
<!-- many thanks to our partners section START-- >
<div class="container">
<?php
(have_rows('what_our_partners_have_to_say_section_single')):
// check if the repeater field has rows of data
if( have_rows('what_our_partners_have_to_say_section_single') ):
// loop through the rows of data
while ( have_rows('what_our_partners_have_to_say_section_single') ) : the_row();
?>
<div class="row">
<div class="col-md-6">
<?php the_sub_field('title_of_many_thanks_to_our_partners_section_single'); ?>
<?php the_sub_field('text_area_for_many_thanks_to_our_partners_section_single'); ?>
</div>
<div class="col-md-6">
</div> <!-- close col md 6 -->
</div> <!-- close row -->
<?php
endwhile;
else :
// no rows found
endif;
?>
</div> <!-- close container -->
Rempty answers:
Hello
I see an error in your code
<?php
(have_rows('what_our_partners_have_to_say_section_single')):
// check if the repeater field has rows of data
if( have_rows('what_our_partners_have_to_say_section_single') ):
// loop through the rows of data
while ( have_rows('what_our_partners_have_to_say_section_single') ) : the_row();
you must remove the
(have_rows('what_our_partners_have_to_say_section_single')): and only use
// check if the repeater field has rows of data
if( have_rows('what_our_partners_have_to_say_section_single') ):
// loop through the rows of data
while ( have_rows('what_our_partners_have_to_say_section_single') ) : the_row();
I think this is generating an error and the page not render properly
Arnav Joy answers:
You getting only single display right now?
Arnav Joy comments:
Please test following code
<div class="container">
<?php
// check if the repeater field has rows of data
if( have_rows('single_programme_details') ): $prog_wom = 0;
// loop through the rows of data
while ( have_rows('single_programme_details') ) : the_row(); $prog_wom++ ;
if ($prog_wom % 2 == 0) { ?>
<div class="row">
<div class="col-md-6">
<?php $prog_womanity_section_single_image = get_sub_field('image_for_the_programme_section_single'); ?>
<img src="<?php echo $prog_womanity_section_single_image['url']; ?>" alt="<?php echo $prog_womanity_section_single_image['alt']; ?>">
</div>
<div class="col-md-6">
<?php the_sub_field('title_of_programme_section_single'); ?>
<?php the_sub_field('text_area_for_programme_section'); ?>
</div>
</div>
<?php } else { ?>
<div class="row">
<div class="col-md-6">
<?php the_sub_field('title_of_programme_section_single'); ?>
<?php the_sub_field('text_area_for_programme_section'); ?>
</div>
<div class="col-md-6">
<?php $prog_womanity_section_single_image = get_sub_field('image_for_the_programme_section_single'); ?>
<img src="<?php echo $prog_womanity_section_single_image['url']; ?>" alt="<?php echo $prog_womanity_section_single_image['alt']; ?>">
</div>
</div>
<?php }
endwhile;
endif;
reset_rows();
?>
</div> <!-- close container -->
<!-- repeating information sections - one per row END -->
<!-- many thanks to our partners section START-- >
<div class="container">
<?php
// check if the repeater field has rows of data
if( have_rows('what_our_partners_have_to_say_section_single') ):
// loop through the rows of data
while ( have_rows('what_our_partners_have_to_say_section_single') ) : the_row();
?>
<div class="row">
<div class="col-md-6">
<?php the_sub_field('title_of_many_thanks_to_our_partners_section_single'); ?>
<?php the_sub_field('text_area_for_many_thanks_to_our_partners_section_single'); ?>
</div>
<div class="col-md-6">
</div> <!-- close col md 6 -->
</div> <!-- close row -->
<?php
endwhile;
else :
// no rows found
endif;
?>
</div> <!-- close container -->
Hugo Gonçalves answers:
Hi mattp!
On the second one you're missing the if.
Might be that.
(have_rows('what_our_partners_have_to_say_section_single')):