Multiple Loops for each Category, More Efficient Way to Query Categories?
-
I’ve got a page I’m showing multiple categories on, with each category displaying their respective posts. I’m thinking there’s got to be a more efficient way of running through every category, rather than just running a loop x number of times. For example:
<?php $one_query = new WP_Query( 'category_name=one' ); ?> <?php while ($one_query -> have_posts()) : $one_query -> the_post(); ?> <!-- stuff --> <?php endwhile;?> <?php rewind_posts(); ?> <?php $two_query = new WP_Query( 'category_name=two' ); ?> <?php while ($two_query -> have_posts()) : $two_query -> the_post(); ?> <!-- stuff --> <?php endwhile;?> <?php rewind_posts(); ?> . . .
So say I have 10 categories, is just running 10 loops for each category the only way? TYIA.
- The topic ‘Multiple Loops for each Category, More Efficient Way to Query Categories?’ is closed to new replies.