Count how many H5 are in the description.

New Member
2 0 0

Hi All,

 

I have hopefully a quick question which is getting annoying my side.

 

I am using easy tabs for the tabbing of content. However, I only want to show tabs if the description has > 1 h5.

 

Otherwise, only show the description. I have places my attempt below but it doesn't work and I'd love the insight into why.

 

I'm a newb with Shopify so still much to learn.

 

Huge thank you in advance.

 

{% assign testString = 'product.description' %}
{% assign splitString = testString | split:"h5"  %} 
    {% if splitString.size > 1 %} 
      {% include 'product-description-tabs' %}
    {% else %}
      {{ product.description }}
{% endif %}
0 Likes
Highlighted
Shopify Partner
1657 278 347

Hi @govel 

Your code most of right just some issue:

you have used 'product.description' its as string because you have added single comma and split from "</h5>", like bellow:

 

 

{% assign testString = product.description %}
{% assign splitString = testString | split:"</h5>"  %} 
    {% if splitString.size > 1 %} 
      {% include 'product-description-tabs' %}
    {% else %}
      {{ product.description }}
{% endif %}

 

Want to modify or custom changes on store hire me.
If helpful then please Like and Accept Solution.
Email: jasoliyabrijesh123@gmail.com
Skype: jasoliya.brijesh
1 Like
New Member
2 0 0

You are awesome.

 

I thought it would be something stupid like that.

 

Really appreciate the help.

 

Liam

0 Likes