Support

Account

Home Forums Add-ons Repeater Field Combine results from multiple repeater fields

Solved

Combine results from multiple repeater fields

  • If I had the same repeater field on a few different pages, what would be the best way to get the repeater field entries from all those pages and combine them, and then sort them all by a field value? Though I don’t yet know exactly how (going to research it), I imagine I could get each repeater field and put its entries into an array and then get the next repeater field and add that onto the same array and then once all repeater fields have been gone through I could sort the array by a particular value… Unless there is a better way?

    Thanks,
    Chris

  • Hi @AKA Digital

    To achieve the above, you would:

    1. Perform a get_posts query to load and loop through the desired post objects
    2. For each post object, load the repeater field data via get_field and add each row to a variable (defined outside of the loop)
    3. After your loop is complete, this variable will not hold all your rows of repeater field data
    4. Sort the variable just like in this tutorial:
    http://www.advancedcustomfields.com/resources/how-to/how-to-sorting-a-repeater-field/

    Good luck

    Thanks
    E

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

The topic ‘Combine results from multiple repeater fields’ is closed to new replies.