Thanks James! The thing is that it is a flexible content or repeater (both can do the work) and I don’t know how many elements will be there so I need to add a counter and some sort of “magic” so it knows when an element is the first one of each row.
Now I have:
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'):?> <div class="medio-tribuna one-fourth 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;
It is working but every element is first element… I need class”first” to be added only to first of each row (of 4)
Does it make any sense?
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
ACF PRO’s Flexible Content field allows you to create smaller pieces of UI and compose them into whole flexible patterns. In our latest article, we show how to use it to create swappable site sections and integrate it all in a theme.https://t.co/ZRocH8oJSp— Advanced Custom Fields (@wp_acf) January 24, 2023
© 2023 Advanced Custom Fields.