Support

Account

Home Forums Add-ons Repeater Field How do I sort repeater field by ID DESC

Solving

How do I sort repeater field by ID DESC

  • I’m wondering how to display, in the backoffice, only the 20 last field according to their post_id DESC.

    A group of field generated contain a date and value. I guess in the data base there’s post_id corresponding for each group and want to sort it following it.

    I used the max row =20, but i could not found where to specify that i need it sorted by post_id DESC.

    Thank you a lot !

  • Exemple :In the picture i’m aiming to display it as :

    24/12/2013 8

    23/12/2013 99

    20/12/2013 10

    Thanks a lot !

  • Hi @lenar ,

    You could hook into the acf/load_value as in the example below.

    add_filter('acf/load_value/type=repeater', 'my_acf_load_value', 10, 3);
    function my_acf_load_value( $rows)
    {
      array_multisort($rows, SORT_ASC);
      return $rows;
    }

    Hope this helps.

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

You must be logged in to reply to this topic.