i am using the following code to get displayed the following text :
but i want to display all this in descending order as :
<?php if( have_rows('rom') ): ?>
<ul>
<?php while( have_rows('rom') ): the_row(); ?>
<li><?php the_sub_field('rom_name'); ?></li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
This is a small example i have considered, but im planning to do a big task using this.
or if not this then what could be done so that when i add a new sub field in the repeater field, then the new added field is placed on the top rather than going at the last?
Hi @harshmeet
Please read over the following article:
http://www.advancedcustomfields.com/resources/how-to-sorting-a-repeater-field/
This should help understand how to sort the repeater field array
Cheers
E
Try this
<div class="main-div">
<?php $outs = array(); if( have_rows('main_field') ): $i = 0;
while ( have_rows('main_field') ) : the_row(); ob_start(); $i++; ?>
<div class="question-answer-template">
<p><?php the_sub_field('sub_feild');?></p>
</div>
<?php $outs[] = ob_get_clean(); endwhile;
else :
endif;
$outs = array_reverse($outs);
echo implode($outs);
?>
</div>