Home › Forums › Add-ons › Repeater Field › Repeater display Data on (2) Columns of a Table? › Reply To: Repeater display Data on (2) Columns of a Table?
Hi @wpdragon
I have whipped up some code which should produce the desired markup. Please take some time to read over and understand it line by line before using it:
<?php
$i = 0;
if( have_rows('list_of_games') ): ?>
<table class="tg-table-plain">
<?php while( have_rows('list_of_games') ): the_row(); $i++;
$post = get_sub_field('game_name');
if( empty($post) )
{
continue;
}
setup_postdata( $post );
?>
<?php if( $i == 1 ): ?>
<tr>
<?php endif; ?>
<td>
<div class="image">
<img src= "<?php $image = get_sub_field('image'); echo $image['sizes']['medium']; ?>" />
</div>
<div class="title">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</div>
<div class="snippet">
<?php the_sub_field('game_snippet'); ?>
</div>
<div class="list-of-games">
<?php the_sub_field('list_of_games'); ?>
</div>
</td>
<?php if( $i == 2 ): $i = 0; ?>
</tr>
<?php endif; ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
<?php endif; ?>
Thanks
E
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 wouldn’t be so widely used in WordPress if it didn’t have some pretty amazing capabilities. In this article, we look at a few of the features we’ll discuss during “7 things you didn’t know you could do with ACF” at #WPEDecode later this month. https://t.co/5lnsTxp81j pic.twitter.com/Yf0ThPG1QG
— Advanced Custom Fields (@wp_acf) March 16, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.