how to tell if a post is in one of many categories
-
So my posts are all in at least two and sometimes more categories. I want to do some things conditionally is each post based on whether it is in a particular one, regardless of whether it is in other categories as well.
if ($cat==2)
doesn’t work, because the post might be in 1 & 2, and so evaluates as false.
Perhaps I just need some PHP syntax help for how to ask if a variable contains a particular value – as opposed to being equal to a particular value.
I’ve also considered putting all the category values into an array and then evaluating that. But I don’t really understand arrays well enough to do this.
Any tips?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘how to tell if a post is in one of many categories’ is closed to new replies.