how to tell if a post is in one of many categories (4 posts)

  1. Ruby Sinreich
    Posted 11 years ago #

    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?

  2. Beel
    Posted 11 years ago #

    search for threads about in_category - and click on my member link and find the "switch off" thread to which I posted.

  3. Ruby Sinreich
    Posted 11 years ago #

    Thanks, Beel!

  4. Ruby Sinreich
    Posted 11 years ago #

    Why didn't I ask you sooner! ;} This did just the trick, I am just not used to all these cool 1.3 variables yet.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.