I have this code:

{if segment_1 != "slug1" || segment_1 != "slug2"}<h2>Text</h2>{/if}

For some reason this does not work with the second instruction after the OR operator. If I remove the OR operator and the following code it is fine ie.

{if segment_1 != "slug1"}<h2>Text</h2>{/if}

The OR operator seems to be the problem here. Can anyone shed some light on this?

  • So just to clarify, the example of {if segment_1 == "slug1|slug2"} instead of {if segment_1 == "slug1" OR segment_1 == "slug2"} isn't correct, is that right?
    – edward
    Jan 9, 2020 at 23:15
  • @edward If the first snippet of code works for you, it's the equivalent of the second snippet, just shorthard. If the first one does not work, then use the second snippet.
    – Anna_MediaGirl
    Jan 10, 2020 at 17:47

1 Answer 1


In your case here, because of the double "!=", use "AND" instead of "OR":

{if segment_1 != "slug1" AND segment_1 != "slug2"}<h2>Text</h2>{/if}

OR use:

{if segment_1 == "slug1" OR segment_1 == "slug2"}

DOCS: Logical Operator

  • I was thinking that by using AND both statements would need to be true in order for the <h2> to appear. I thought that OR made more sense. Have I got my thinking upside down and back to front? Mar 17, 2013 at 16:41
  • 2
    Because both statements need to be true (segment_1 should not be "slug1" AND not be "slug2"), then AND is correct. Just to clarify, "AND" or "&&" are both valid operators, as is "OR" or "||". Mar 17, 2013 at 17:04
  • You're welcome... Did my answer help solve your issue? If yes, select the answer as correct by clicking on the checkmark to the left.
    – Anna_MediaGirl
    Mar 17, 2013 at 23:26
  • 4
    Little known fact, you can actually do {if segment_1 == "slug1|slug2"} instead of {if segment_1 == "slug1" OR segment_1 == "slug2"}.
    – Tyssen
    Mar 18, 2013 at 3:04
  • Not sure that this method with the pipe is still working as of ee5 -- it didn't work for me just now.
    – edward
    Jan 8, 2020 at 2:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.