I am looking for something very similar to this questionthis question. However, the answer provided there seems strange to me. I don't know what the arguments
posts_per_page=-1 and it seems more like a hack to me than an actual solution.
I tried the following, which loops the first 6 categories and it works great. However, I want to exclude some categories from this, for instance 1 and 4. I am not entirely sure how to approach this.
<div id="category-posts-content"> <?php $i = 0; while ($i < 7) : ?> <?php query_posts('cat='.$i.'&posts_per_page=3'); ?> <?php if ( have_posts() ) : ?> <div class="subject"> <h3><?php single_cat_title(); ?></h3> <ul> <?php while ( have_posts() ) : the_post(); ?> <li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> </ul> </div> <?php endif; ?> <?php $i++; ?> <?php endwhile; ?> <?php wp_reset_query(); ?> </div>
NOTE: some posts belong into more than one category!