Home › Forums › Add-ons › Repeater Field › Every row in an own DIV
Hello, i hope you can help me with the following problem:
I have a Team-Member-Site with the fields
name_des_anwalts
bild_des_anwalts
schwerpunkte_des_anwalts
These fields should display on the website in a box, so I have put a div around it (box_anwaelte):
<div class="box_anwaelte">
<?php
if (have_rows("anwaelte")):
while (have_rows("anwaelte")): the_row();
// vars
$employeeName = get_sub_field("name_des_anwalts");
$employeeImage = get_sub_field("bild_des_anwalts");
$employeeContent = get_sub_field("schwerpunkte_des_anwalts"); ?>
<h2><?php echo $employeeName; ?></h2>
<img class="img_anwaelte" alt="Bild von <?php echo $employeeName; ?>" src="<?php echo $employeeImage; ?>">
<br>
<?php echo $employeeContent;
endwhile;
endif;
?>
<?php
$image = get_field('bild_des_anwalts');
if( !empty($image) ): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif; ?>
</div>
But when I have two rows they are displayed in one (the same) box. How can I get it that every row is in its own div-box?
Thanks in advance!
<?php
if (have_rows("anwaelte")):
while (have_rows("anwaelte")): the_row();
?>
<div class="box_anwaelte">
<?php
// vars
$employeeName = get_sub_field("name_des_anwalts");
$employeeImage = get_sub_field("bild_des_anwalts");
$employeeContent = get_sub_field("schwerpunkte_des_anwalts");
?>
<h2><?php echo $employeeName; ?></h2>
<img class="img_anwaelte" alt="Bild von <?php
echo $employeeName; ?>" src="<?php echo $employeeImage; ?>">
<br>
<?php echo $employeeContent; ?>
</div>
<?php
endwhile;
endif;
?>
Wow, that was fast! Thank you so much! It seems like I had a blind spot!
I must have happened to look at the new topics at just the right time.
The topic ‘Every row in an own DIV’ is closed to new replies.
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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.