James
James

Reputation: 618

Shopify Liquid Template - OR operator not working

I'm trying to achieve something quite simple.

My code is the following:

{% if template != 'index' or template != 'page.jump' %}

I then want to do something if the template isn't equal to those two pages.

However, it doesn't seem to be interpreting anything after or

Either of these work individually, and I've had to resort to nesting if statements which is nasty.

Is there any reason why template won't work with the or operator in a liquid template?

Upvotes: 0

Views: 5925

Answers (2)

Karo
Karo

Reputation: 1

For the liquid it works perfectly in 2 conditions:

  1. Don't use double quotes, just single quotes
  2. Don't start your statement with "Not Equal" != You can use != as the second part of your statement

Example:

{% if product.type == 'Bundle' and product.type != 'Dress'%}

Upvotes: 0

jlcharette
jlcharette

Reputation: 900

Try the "and" operator.

{% if template != "index" and template != "page.jump" %}

There seems to be another way around here: How to use multiple arguments in an if statement with Liquid

Upvotes: 4

Related Questions