Multiple Loops with in_category tag
-
I’ve got a template set up the way I want, and it seems to be working. But I’ve had to use conditional tags in a way opposite to what the WP documentation specifies, and I’d appreciate anyone shedding light on the matter.
What I wanted was to have multiple category-specific post loops on one page (index.php, say). I put this in each loop:
<?php if (in_category('1')) continue;?>
And after each
endwhile
, I have this (is it necessary? It doesn’t seem to make a difference.):rewind_posts();
This works, sort of. What it ended up doing is excluding everything in category one instead, or simply including posts in all categories.
To get a post loop to show only posts in category 1, I had to use:
<?php if (in_category('2') || in_category('3')) continue;?>
or
<?php if (!in_category('1')) continue;?>
to exclude all other categories.
Isn’t in_category() supposed to specify which categories to include rather than exclude?
Thanks.
- The topic ‘Multiple Loops with in_category tag’ is closed to new replies.