Reputation: 479
My PHP script's foreach cycle generates all blog articles information from database and then displays it in one place. I want each article information to be displayed in separate divs. How do I do it?
<div class="blog">
<?php if (count($articles)): foreach ($articles as $article): ?>
<article><?php echo get_excerpt($article); ?><hr></article>
<?php endforeach; endif; ?>
</div>
Upvotes: 0
Views: 238
Reputation: 1294
<div class="blog">
<?php if (count($articles)): foreach ($articles as $article): ?>
<div><article><?php echo get_excerpt($article); ?><hr></article></div>
<?php endforeach; endif; ?>
</div>
Simply surrounds your articles with div's
Upvotes: 0
Reputation: 11717
Wrap your div inside foreach
block
<div class="blog">
<?php if (count($articles)): foreach ($articles as $article): ?>
<div>
<article><?php echo get_excerpt($article); ?><hr></article>
</div>
<?php endforeach; endif; ?>
</div>
Upvotes: 2