Home Forums Add-ons Repeater Field Reverse Repeater Field Order


Reverse Repeater Field Order

  • Hi,

    I’m working on a site with about 9,000 posts, each containing 5-50 rows in a repeater field. The site owner wants to reverse the order of this field in the admin, but not the front-end. Instead of storing the values in reverse order in the DB and relying on every page load to reverse them again (to their original order) on the front-end, it seems like a better approach to reverse the order on the fly in the admin.

    So, I’m using acf/load_value/name=my_field.

    function acf_reverse_repeater( $value, $post_id, $field ) {
        if ( empty($value) ) return $value;
        $value = array_reverse($value);
        return $value;

    So that works great to reverse them on page load in the admin, but when I update the post, I need to reverse them back to their original order before updating the database.

    I thought I could use acf/update_value/name=my_field, but that empties the field altogether, at least when I use the same function as defined above.

    What do I need to do to get this sorted?

    Thank you!

Viewing 1 post (of 1 total)

The topic ‘Reverse Repeater Field Order’ is closed to new replies.