Change Title When It's Too Long

JADIS
Explorer
169 1 19

Good morning,

I would like that when the product title is above 56 characters, the name automatically stops and adds 3 small points. (ONLY for featured collection and collections)

EXAMPLE HOW IT IS NOW:

JADIS_0-1699267749433.png

 

 

EXAMPLE HOW I WOULD LIKE IT TO AUTOMATICALLY DO ABOVE 56 CHARACTERS IN THE TITLE:

JADIS_1-1699267749432.png

 

 

 


website: jadis-shop.com

password: rj


Do you know how to do it ?


thank you very much in advance

Reply 1 (1)
WhiteWater_Web
Shopify Expert
440 16 37

Try something like this; let us know if you need a hand implementing:

 

{% assign max_length = 56 %}
{% assign product_title = product.title %}
{% if product_title.size > max_length %}
{% capture truncated_title %}{{ product_title | truncate: max_length, "" }}...{% endcapture %}
{{ truncated_title }}
{% else %}
{{ product_title }}
{% endif %}

A certified Shopify Partner and Expert, WhiteWater Web (WWW) is a premium digital solutions company specializing in advanced Shopify Dev, Usability/Design, and Online Strategy. WWW has been working with the Shopify platform since 2006.
info@whitewatersolutions.com