Repeater Field

Description

ACF has a power field called a Repeater field, which allows the user to re-use the same set of fields multiple times on a page. This is useful for adding repeated content with an unknown amount of duplications (for example, a list of links.) A Repeater field is called as a loop (see code below). The fields within a repeater are then called using get_sub_field(‘field_name’). The content within the Repeater loop can be wrapped and coded as necessary.

NOTE: There is a setting within the Custom Fields setup for a Repeater that allows a minimum and maximum number of “rows” to be added to the repeater. This is useful for putting a ‘cap’ on the number of entries a user can make.

- if (have_rows('repeater_name')) : 
    - while (have_rows('repeater_name')) : the_row() 
        //Use HTML and PHP to structure as necessary 
        - the_sub_field('sub_field_name') 
    - endwhile 
- endif

 

MENU