I have a wordpress index page where I’m trying to have 7 divs (each for a different category). Within each div I would like the post titles from those specific categories to post. For some reason after the last post, it repeats the divs continuously. I have ended the loops but am a bit confused. Can someone please help?
[php]<?php get_header(); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php $count = 0; ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>[/php]
Gluten Free Living
<div class="cover">
<div class="entry">
<ul>
<?php
query_posts('category_name=gluten-free-living&showposts=-1'); while(have_posts()) : the_post();
?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
</div>
</div>
</div>
<div class="box">
<div class="cats"><span class="tleft">Gluten Free Cooking</span>
<div class="clear"></div>
</div>
<div class="postim"><a href="http://deannasglutenfree.com/gluten-free-cooking"><img src="http://deannasglutenfree.com/wp-content/uploads/2012/04/gf-nutrition.jpg" /></a> </div>
<div class="clear"></div>
<div class="cover">
<div class="entry">
<ul>
<?php
$myposts = get_posts('numberposts=5&category_name=gluten-free-cuisine');
foreach($myposts as $post) :
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
<div class="box">
<div class="cats"><span class="tleft">Gluten Free Nutrition</span>
<div class="clear"></div>
</div>
<div class="postim"><a href="http://deannasglutenfree.com/gluten-free-nutrition"><img src="http://deannasglutenfree.com/wp-content/uploads/2012/04/gf-nutrition.jpg" /></a> </div>
<div class="clear"></div>
<div class="cover">
<div class="entry">
<ul>
<?php
$myposts = get_posts('numberposts=5&category_name=gluten-free-nutrition');
foreach($myposts as $post) :
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
<div class="box">
<div class="cats"><span class="tleft">Gluten Free Uncategorized</span>
<div class="clear"></div>
</div>
<div class="postim"><a href="http://deannasglutenfree.com/gluten-free-nutrition"><img src="http://deannasglutenfree.com/wp-content/uploads/2012/04/gf-nutrition.jpg" /></a> </div>
<div class="clear"></div>
<div class="cover">
<div class="entry">
<ul>
<?php
$myposts = get_posts('numberposts=5&category_name=uncategorized');
foreach($myposts as $post) :
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
<?php if(++$counter % 3 == 0) : ?>
<?php endif; ?>
<?php endwhile; ?>
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
<?php else : ?>
<h1 class="title">Item Not Found</h1>
<p>Sorry, but you are looking for something that maybe has been moved or deleted from my site. You can always do a search.</p>
<?php endif; ?>