multiple loops question
-
hey, I have a question about multiple loops in a template, and basically just want to make sure I am doing it right. say I have a custom template and for whatever reason I want a first loop that displays two posts:
<?php $myPosts = new WP_Query('posts_per_page=2''cat=2,6'); while($myPosts->have_posts()) : $myPosts->the_post(); ?><?php the_content();?> <?php endwhile; ?> //and then for whatever reason another loop(even if could be done in // the first one.. <?php $myPosts = new WP_Query('posts_per_page=1''cat=3'); while($myPosts->have_posts()) : $myPosts->the_post(); ?><?php the_content();?> <?php endwhile; ?>
would that be an okay way of doing this, or is there a better way to have two loops in a template?
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘multiple loops question’ is closed to new replies.