Support

Account

Home Forums Add-ons Repeater Field Show rows in 2 sections – offset 10 rows Reply To: Show rows in 2 sections – offset 10 rows

  • the most useful way (imho) would be: fill values into variables and echo than when needed.

    <?php
    if( have_rows('best_braai_buys',$page_id) ): 
    $i = 0;
    $before_best_braai_buys = '<ul class="group">';
    $after_best_braai_buys = '</ul>';
    $first10_best_braai_buys = ''; //variable for first 10products
    $morethan10_best_braai_buys = ''; //variable for rest of products
    			    
    	while( have_rows('best_braai_buys',$page_id) ): the_row();
    	$i++;
    	$bbb_product_image = '';
    	$bbb_product_description = '';
    	$bbb_product_image = get_sub_field('product_image');
    	$bbb_product_description = get_sub_field('product_description');
    		if( $i > 10 ) {
    			$morethan10_best_braai_buys .=  '<li class=" list-'.$i.'">';
    			$morethan10_best_braai_buys .= '<img src="'.$bbb_product_image.'" alt="'.$bbb_product_description.'" />';
    // adapt/extend with rest of your values ... important => no echo or nonphpcode
    
    			$morethan10_best_braai_buys .= '</li>';
    		} else {
    			$first10_best_braai_buys .=  '<li class=" list-'.$i.'">';
    			$first10_best_braai_buys .= '<img src="'.$bbb_product_image.'" alt="'.$bbb_product_description.'" />';
    // adapt/extend with rest of your values ... important => no echo or nonphpcode
    
    			$first10_best_braai_buys .= '</li>';
    			}
    	endwhile; 
    endif;
    
    //now you can echo everything you like with something between
    
    //first 10 products
    echo $before_best_braai_buys;
    echo $first10_best_braai_buys;
    echo $after_best_braai_buys;
    
    //whatever you wish
    echo $somethingbetween;
    
    //rest of products
    echo $before_best_braai_buys;
    echo $morethan10_best_braai_buys;
    echo $after_best_braai_buys;
    
    ?>