Is this dual loop in my tag.php ok to use?
I have just put this dual loop in my tag.php, its working and from reading the documentaion i think ive done it properly but could somebody please check incase ive made an error or incase there is a better way to do it:
<?php if (have_posts()) : ?> <?php $posts = query_posts($query_string . '&cat=-100&showposts=100'); while (have_posts()) : the_post(); ?> Loop 1 Stuff... <?php endwhile; ?> <?php rewind_posts(); ?> <?php $posts = query_posts($query_string . '&cat=100&showposts=100'); while (have_posts()) : the_post(); ?> Loop 2 Stuff... <?php endwhile; ?> <?php else : ?> My Error Stuff 404 Message... <?php endif; ?>
The top loop is set to exclude a category and the second is set to include the category the first loop excluded.
Adding or removing <?php rewind_posts(); ?> doesnt seem to make a difference but i left it there as i read it was required.
Does it matter having $posts for each loop or do i need to name each loop differently im not sure how that works for query_posts.
The showposts=100 is just there to make sure all the posts for the tag show on the one page, in reality there will probably only 10-15 posts per tag but again i read using a higher number is fine as it will just stop if it runs out of posts before it gets to 100 so is this ok also.
Thanks in advance for any help or advice.
- The topic ‘Is this dual loop in my tag.php ok to use?’ is closed to new replies.