How can I hide tags for a specific product title in my code?

Solved

How can I hide tags for a specific product title in my code?

amazezones
Explorer
82 0 13

Hi

 

I have below code that shows list of tags on top of the page. What I want is, if product title is ''FREE BOOKS" then I don't want these tags to be shown on the top of the page. Could anyone help.

 

     <hr> <!-- Edit Add tags -->     
    <div class="product_tags">
        <lable>Search by Tags:</lable></br></br>
        {% for tag in product.tags %}
                 <a class="link" href="/collections/all/{{ tag | handle }}" rel="tag" style="text-decoration: none" >
                   <span>{{ tag }}</span>
                 </a>
             {% endfor %}
</div>  
      <hr>
Accepted Solution (1)

codewiser
Shopify Partner
81 35 33

This is an accepted solution.

Hey @amazezones 
Please Add below code

 

<hr> <!-- Edit Add tags -->     
{% unless product.title contains 'FREE BOOKS' %}
    <div class="product_tags">
        <lable>Search by Tags:</lable></br></br>
        {% for tag in product.tags %}
                 <a class="link" href="/collections/all/{{ tag | handle }}" rel="tag" style="text-decoration: none" >
                   <span>{{ tag }}</span>
                 </a>
             {% endfor %}
</div>  
{% endunless %}
<hr>

 

If your problem solved then Like & Accept this Solution.
For Designing, Development and custom changes hire us. Email us Or WhatsApp Or Skype.

View solution in original post

Replies 3 (3)

PaulNewton
Shopify Partner
7450 656 1562

Wrap it with an unless conditional 

{% unless product.title == 'FREE BOOKS' %}

{% endunless %}

or 
{% unless product.title contains 'FREE BOOKS' %}

{% endunless %}


or make the normal condition the else output in an if else condition
{% if product.title == 'FREE BOOKS' %}

{% else %}
  {% comment %} paid books normal output {% endcomment %}
{% endunless %}

Note case sensitive, to get around that compare to a normalized title variable: {% assign normalized_title = product.title | downcase %}  

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


codewiser
Shopify Partner
81 35 33

This is an accepted solution.

Hey @amazezones 
Please Add below code

 

<hr> <!-- Edit Add tags -->     
{% unless product.title contains 'FREE BOOKS' %}
    <div class="product_tags">
        <lable>Search by Tags:</lable></br></br>
        {% for tag in product.tags %}
                 <a class="link" href="/collections/all/{{ tag | handle }}" rel="tag" style="text-decoration: none" >
                   <span>{{ tag }}</span>
                 </a>
             {% endfor %}
</div>  
{% endunless %}
<hr>

 

If your problem solved then Like & Accept this Solution.
For Designing, Development and custom changes hire us. Email us Or WhatsApp Or Skype.
amazezones
Explorer
82 0 13

its working, thx