Hi, I have a need to put each post into a div (which I have done) but my issue is that I also need every 3 divs to be wrapped in another div.
[wrapper [post 1] [post 2] [post 3] wrapper]
[wrapper [post 4] [post 5] [post 6] wrapper]
[wrapper [post 7] [post 8] [post 9] wrapper]
I have been able to put the posts into their own divs, however I am having trouble creating that wrapper every 3 posts.
Here is my code:
<?php $count = 0; query_posts('cat=21'); if(have_posts()) : while(have_posts()) : the_post(); $open = !($count%1) ? '<div class="span4 portfolio-item">' : ''; $close = !($count%1) && $count ? '</div>' : ''; echo $close.$open; ?>
Any ideas how I would create the wrapper as indicated above?
- The topic ‘Put posts into divs?’ is closed to new replies.