Truncated description on collection page

pearlerwork
Shopify Partner
71 1 10

I'm showing a truncated description on the collection page using this code:

{{ product.description | strip_html | truncate: 170 }} 

 

I'm wondering how I might be able to hide unwanted text - I've seen some blog posts use this:

<!--split-->

 

But I'm not sure how it translates in this context? The pink arrow shows the text I don't want to appear. 

 

Image 2021-07-13 at 11.12.01 am.png

Website → 

Replies 4 (4)

mkamalkayani
Shopify Partner
87 8 15

Hi,

what do you mean by "unwanted text"?

Maybe this is helpful: Liquid string filters

pearlerwork
Shopify Partner
71 1 10

@mkamalkayani Thanks - in my original post, you can see I've highlighted some text I don't want to appear. Perhaps it would be good if only the first <p> tag text appeared:

<p>This lightly foaming shampoo helps create and maintain a healthy hair growing environment. It is formulated to revitalize your scalp microbiome and gently remove follicle-clogging sebum.</p>
<!-- split -->
<h5><span>Ingredients</span></h5>
<p>Water (Aqua), Sodium Cocoyl Isethionate, Decyl Glucoside, Cocamidopropyl Hydroxysultaine, Cocamidopropyl Betaine, Cetrimonium Chloride, Glycol Distearate, Phenoxyethanol, Ethylhexylglycerin, Polyquaternum-10</p>
mkamalkayani
Shopify Partner
87 8 15

I am sorry, I couldn't understand your question.

I can't provide a good solution unless I have a good understanding of the problem.

LitExtension
Shopify Partner
4860 1001 1133

You just need to change the code:
{{ product.description | strip_html | remove: "text" | truncate: 170 }}
Ex: {{ product.description | strip_html | remove: "ingredients" | truncate: 170 }}
Hope it helps!

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify