Home Forums Add-ons Repeater Field Filter Sort Repeater Field in Backend


Filter Sort Repeater Field in Backend

  • Hi, i’ve created a repeater field that it is generated by registering contacts. For example, my repeater field have the following sub fields:
    – name
    – email
    – message

    This is registered in a frontend form.

    In my back of WordPress appears like this (chek the order):

    – name 1, email 1, message 1
    – name 2, email 2, message 2
    – name 3, email 3, message 3

    I want to add a filter that appears like this (automatically with the inverted order and for a specific custom post type called “Message Contact”):

    – name 3, email 3, message 3
    – name 2, email 2, message 2
    – name 1, email 1, message 1

    Please, can you help me?? Thanks

  • i don’t know if it is possible to filter at backend without one of this:

    • a additional field that contains the “count”
    • a save date_time-field
    • any other (own) field that you can order by

    where you can order by ASC/DESC

    if you have one of this field, than you can use this how-to to order your repeater

    if it is only for frontend: than it is no need for such a field. just use something like this
    $reversed = array_reverse($your_repeater);

  • Thanks for answer… ACF’ support commented me about array_reverse, too. Thye give me this code:

    function my_acf_load_value( $value, $post_id, $field ) {
    // bail early if no value
    if( empty($value) ) {
    return $value;
    // return
    return array_reverse($value);
    add_filter(‘acf/load_value/name=my_repeater_field_name’, ‘my_acf_load_value’, 10, 3);

    But appears the next error:

    Warning: array_reverse() expects parameter 1 to be array, string given in C:\xampp\htdocs\new_useem_wp\wp-content\themes\useem\functions.php on line 203

    In line 203:
    return array_reverse($value);

    What could be happening?


  • I’m running into the exact same issue, I’ve noticed that $value is just a string equal to the number of rows I have saved in the repeater field.

  • Yes, I’ve put print_r($value) and it returns the number of rows. Ther should be some way that return the array of the rows…. but I dont know how

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

The topic ‘Filter Sort Repeater Field in Backend’ is closed to new replies.