multiple loops > php help
-
Hi
I need 3 separate loops on my category pages – one that shows the latest 5 posts from the category, another that shows the 5 before that, and then another that shows the 12 before that. I have 42 categories.
Currently, for each section, I am running through all 42 categories in one huge if statement. That means 3 huge if statements for each category page. I find it hard to believe that I am doing it in the most efficient way! Any help would be greatly appreciated 🙂
Example of the current code:
<?php if (is_category('1')) : ?> <?php $recent = new WP_Query("cat=1&showposts=12&offset=10"); while($recent->have_posts()) : $recent->the_post(); ?> "><?php the_title(); ?> <?php endwhile; ?> <?php elseif (is_category('2')) : ?> <?php $recent = new WP_Query("cat=2&showposts=12&offset=10"); while($recent->have_posts()) : $recent->the_post(); ?> "><?php the_title(); ?> <?php endwhile; ?> ... <?php elseif (is_category('42')) : ?> <?php $recent = new WP_Query("cat=42&showposts=12&offset=10"); while($recent->have_posts()) : $recent->the_post(); ?> "><?php the_title(); ?> <?php endwhile; ?> <?php endif; ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘multiple loops > php help’ is closed to new replies.