Support

Account

Home Forums ACF PRO Create columns Front-End Reply To: Create columns Front-End

  • Hi @pepacobos

    In this case, you should be able to do it like this:

    if( have_rows('tribuna') ):
    
    	while( have_rows('tribuna') ): the_row(); 
    	
    		// vars
    		$image = get_sub_field('imagen');
    		$content = get_sub_field('resumen');
    		$link = get_sub_field('enlace');
    		$title = get_sub_field('titulo');
    
    		if( get_row_layout() == 'articulo_tribuna'):
            
                if(get_row_index() % 4 == 1){
                    $first = ' first';
                }else{
                    $first = '';
                }
                
            ?>
    
    				<div class="medio-tribuna one-fourth<?php echo $first; ?>">
    
    				<?php if( $link ): ?>
    					<a href="<?php echo $link; ?>">
    				<?php endif; ?>
    	
    					<img src="<?php echo $image; ?>" />
    	
    				<?php if( $link ): ?>
    					</a>
    				<?php endif; ?>
    				    <h2><?php echo $title; ?></h2>
    				    <?php echo $content;?></div> 
    		    
    		    	<?php
    
            endif;
            
        endwhile; 
    
        else: //no layouts found
    
    endif;

    You can also do the calculation manually like this:

    if( have_rows('tribuna') ):
    
        $i = 1;
    
    	while( have_rows('tribuna') ): the_row(); 
    	
    		// vars
    		$image = get_sub_field('imagen');
    		$content = get_sub_field('resumen');
    		$link = get_sub_field('enlace');
    		$title = get_sub_field('titulo');
    
    		if( get_row_layout() == 'articulo_tribuna'):
            
                if($i % 4 == 1){
                    $first = ' first';
                }else{
                    $first = '';
                }
                $i++;
                
            ?>

    I hope this helps 🙂