Home Forums Add-ons Repeater Field ACF Repeater show content in blocks


ACF Repeater show content in blocks

    • jarvis

    • April 16, 2014 at 5:37 pm

    Hi All

    I really hope someone can help on this. I’ve a simple repeater but I need to return the values in blocks of 3. Like so:

    • Item 1
    • Item 2
    • Item 3
    • Item 4
    • Item 5
    • Item 6
    • Item 7
    • Item 8
    • Item 9

    I can get the repeater to divide into the 3 blocks but can’t return 3 rows per block

    How can I do this?


  • Hi,
    I have an idea it’s not realy clean code, could use some improvement but it should work.

    // check if the repeater field has rows of data
    if( have_rows('repeater_field_name') ):
     	// loop through the rows of data
        $i = 0;
        while ( have_rows('repeater_field_name') ) : the_row();
        $get_value = get_sub_field('sub_field_name');
        if($i == 1 || $i == 4 || $i == 7 ){
            echo '<ul>'
            // display a sub field value
            echo '<li>' . $get_value . '</li>'
        if($i == 3 || $i == 6 || $i == 9 ){
            echo '</ul>'
    else :
        // no rows found

    well that is not realy great if you want to change the number of content on each blocs but it could be perfecter for exemple if you add a custom field on you repeater (a true/false for example that set the oppening <ul> and another one that sets the closing </ul>) you could look for those on the while loop and output an oppening or closing ul before or after an element

    • jarvis

    • April 17, 2014 at 9:06 pm

    Thanks l.pirondini that really helped!

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.