php - Div not wrapping around all items in a loop
I got 2 sections on a page. You can see it here: http://www.equitasmg.com/who-we-are-2/
Both sections have a<div>
wrapped around them, but the first section "Our Leadership" seems to not like the<div>
. The<div>
wraps around the first item in the section but does not wrap around all the items.
Here is the PHP for both sections.
First section
<center><h2>Our Leadership</h2></center>
<center><div>
<?php
$people= get_field('people');
$a=0;
foreach ($people as $r) {
$a++;
?>
<div >
<img src="<?php echo $r['image']['sizes']['team'];?>" >
<h3>
<?php echo $r['name'];?>
</h3>
<div >
<h4><?php echo $r['position'];?></h4>
</div>
<?php echo $r['intro_text'];?>
<?php if ($r[ 'learn_more_text']) { ?>
<a href="#" data-reveal-id="<?php echo sanitize_title($r['name'] );?>">Learn More</a>
<?php } ?>
<?php if ($r[ 'learn_more_text']) { ?>
<div id="<?php echo sanitize_title($r['name'] );?>" data-reveal aria-labelledby="modalTitle" aria-hidden="true" role="dialog">
<h3><?php echo $r['name'];?></h3>
<div >
<?php echo $r['position'];?>
</div>
<div >
<?php echo $r['learn_more_text'];?>
</div>
<a aria-label="Close">×</a>
</div>
</div>
<?php } ?>
</div>
<?php } ?>
</div></center>
<div ></div>
Second section
<center><h2>Our Team</h2></center>
<center><div>
<?php
$people2= get_field('people_bottomsection');
$a=0;
foreach ($people2 as $r) {
$a++;
?>
<div >
<img src="<?php echo $r['image']['sizes']['team'];?>" >
<h3>
<?php echo $r['name'];?>
</h3>
<div >
<h4><?php echo $r['position'];?></h4>
</div>
<?php echo $r['intro_text'];?>
<?php if ($r[ 'learn_more_text']) { ?>
<a href="#" data-reveal-id="<?php echo sanitize_title($r['name'] );?>">Learn More</a>
<?php } ?>
<?php if ($r[ 'learn_more_text']) { ?>
<div id="<?php echo sanitize_title($r['name'] );?>" data-reveal aria-labelledby="modalTitle" aria-hidden="true" role="dialog">
<h3><?php echo $r['name'];?></h3>
<div >
<?php echo $r['position'];?>
</div>
<div >
<?php echo $r['learn_more_text'];?>
</div>
<a aria-label="Close">×</a>
</div>
</div>
<?php } ?>
</div>
<?php } ?>
</div></center>
<div ></div>
Answer
Solution:
You just got extra div.
First section you got extra div here
People are also looking for solutions to the problem: http failure during parsing for
Source
Share
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.