Support

Account

Home Forums Add-ons Repeater Field Add a class on every third row Reply To: Add a class on every third row

  • Hey Kawaisin,

    This should do the trick (untested):

    <?php
    if(have_rows("tombstones"))
    {
    	$tombstonescount = 0;
    	while( have_rows("tombstones") )
    	{
    		$tombstonescount++;
    		$class = '';
    		$image = get_sub_field('tombstone_image');
    		if(i % 3 == 0)
    		{
    			$class .= 'last';
    		}
    		?>
            <div class="one_third <?php echo $class;?>">
            <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" title="<?php echo $image['title'] ?>" />
            </div>
            <?php
    	}
    }
    ?>