Support

Account

Home Forums Add-ons Repeater Field Inverted repeater

Solved

Inverted repeater

  • Hi,

    Is it possible to invert the repeater rows in the front-end?

    I know I can sort repeater fields by using values from sub-fields, but that’s not what I’m after.

    What I want is to simply display this particular repeater field backwards πŸ™‚

    Thanks!

  • I actually managed this on my own…
    Just placed the field in an array and used ‘array_reverse’.

    Sorry for the spam πŸ™‚

  • Code sample would be fantastic!

  • Here’s how I achieved this:

    $rowsArray = get_field(‘repeater_field_name’);
    $rows = array_reverse(‘$rowsArray’);

    if($rows) {

    foreach($rows as $row) {

    //ETC – see Repeater Field Docs for how to display sub fields.

  • Sorry, I wasn’t near any internet yesterday…

    That’s exactly how I did it πŸ™‚

  • Does this still work with ACF Pro? I can’t seem to get it to work and I need to do the same thing!

  • Hi there,
    The code should still work. Kindly share with us the code that you are having a problem with so that we can have assist in debugging.

  • The above code worked for me with one tweak. Do not put single quotes around the $rowsarray variable.

    $rowsarray = get_field('financialreports');
    $rows = array_reverse($rowsarray);
    if($rows)
Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Inverted repeater’ is closed to new replies.