I just saw a similar question about Pages:
http://wordpress.org/support/topic/162289?replies=4#post-710615
I am not a coder by any means but I think the logic should be similar.
this covers the php part of your question fairly well.
http://mgeisler.net/php-tutorial/control-structures/
specifically the bits that go on about this sort of stuff:
To compare the value of a variable up against other variables or numbers, you have a number of different comparison-operators:
* ==: Is equal to,
* !=: Is not equal to,
* <: Is strictly less than,
* <=: Is less than or equal to,
* >: Is strictly greater than,
* >=: Is greater than or equal to,
* && (and): Both left and right arguments must be true,
* ||, or: Left or right argument must be true (or both),
* ^, xor: Exactly one of the left and right arguments must be true.
* !: Negation, changes true to false and false to true.
Using these operators you can construct every Boolean expression you’ll ever need. Take for example the following if-statement:
if (($x == 0 && $y != 0) || ($x != 0 && $y == 0))
// Exactly one of $x and $y is zero.
}
rudolf45,
Thanks for the link. But what that doesn’t answer is the part I’m having the most trouble with. How do I phrase an if condition to result in true if a post falls into a category other than 26 & 3?
grrrr.
if ($cat != 26 && $cat != 3)
please read.
whooami,
I could have sworn I tried that.
Thank you for your time. I’ll get back to this in the morning with fresh eyes.
if (!is_category(’26’) && !is_category(‘3’) )
Didnt I just explain the logic?
Yes you did explain it. And I said thank you.
However, neither
if ($cat != 26 && $cat != 3)
or
if (!is_category('26') && !is_category('3') )
worked.
When presented with a category that is part of categories 26, 3 & 1, each of these statements evaluated as true. Likewise, they evaluated as true for a post in categories 26 & 3.
Nevermind…I’m going to try a different solution.
if ($cat != 26 && $cat != 3)
thats not going to work because I made up the variable $cat for the sake of the explanation 🙂
Its easier to type.
is_category checks to see if a particular category page is being displayed.
in_category checks to see if a given post is in a category.
you need this:
if (!in_category('26') && !in_category('3') )
That one doesn’t work either I tried that before I even posted this topic.
Thank you for your help. I’m going to try to solve the problem a different way.