Support

Account

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

  • 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');
        
        $i++;
        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>'
         } 
        endwhile;
     
    else :
     
        // no rows found
     
    endif;

    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