Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Shopify Liquid Code Help

Featured Replies

Hi all,

Just a quick one here. I am trying to hide tags that contain 'cf-' and '_'.

Here is the code that I currently have and it is working fine:

                {% unless tag contains 'meta-related-collection-' %}
              	{% unless tag contains 'cf-' %}
              	{% unless tag contains '_' %}
                  content
                {% endunless %}
              	{% endunless %}
              	{% endunless %}

I was trying to write it like this:

                {% unless tag contains 'meta-related-collection-' or 'cf-' or '_' %}
                  content
                {% endunless %}

But that removes all Tags.

Is there a better way to write this code?

Thanks,
Al.

You may need to do something like this.

{% if tag contains 'meta-related-collection-' or tag contains 'cf-' or tag contains '_' %}
{% endif %}

You will need to ask Shopify directly, but basically it would be nicer to pass in an array instead.

{% assign supportedTags = ['meta-related-collection-', '-', 'cf-'] %}

{% if tag in supportedTags %}
   content
{% endif %}

This code won't work, it's a mixture of a similar language called Twig, and Shopify's Liquid, but it should give you an indication to at least go back to Shopify with.

Edited by Jack

  • Author

Hey Jack, thanks for the reply. I had posted the above in the Shopify Forums but the post disappeared, my posts are not displayed for some reason there and sometimes I get locked out of the Forums, been onto Shopify support a few times about it but I don't think they really have an answer why.

 

Anyway, I have updated the code to this:

                {% unless tag contains 'meta-related-collection-' or tag contains 'cf-' or tag contains '_' %}
                  content
                {% endunless %}

And that has also worked!

 

Thanks again mate =)

Hey Jack, thanks for the reply. I had posted the above in the Shopify Forums but the post disappeared, my posts are not displayed for some reason there and sometimes I get locked out of the Forums, been onto Shopify support a few times about it but I don't think they really have an answer why.

 

Anyway, I have updated the code to this:

                {% unless tag contains 'meta-related-collection-' or tag contains 'cf-' or tag contains '_' %}
                  content
                {% endunless %}

And that has also worked!

 

Thanks again mate =)

 

The array method would be my preferred way. If you ever need to add to that list of selectors then it will start to become messy. You can always bother Shopify on Twitter, if you have an account.

 

Glad it's working anyway. It's impossible to test because I don't have an account.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.