Pulling a small part of product description on collections page

Highlighted
New Member
2 0 0

Hi

I have seen this problem a few times but not seen a resolution for it. I only want the first sentence of my Product Description to show up on the Collections page. At the moment, this is the liquid code I'm pulling

<p>{{ product.description }}</p>

I know you can truncate words/characters but the description is different for each prodcut so that won't work. This is an image of what I'm trying (it's currently truncating words)

 

0 Likes
Highlighted
Shopify Partner
223 1 24

You could use the string filter "slice" like so:

{% assign product_description = product.description | split: '.' %}

{{ product_description.first }}.

This should theoretically bring you the fisrt sentence, since it splits per each "." And the description to the first "." should be the first sentence. You would have to format all your descritpions to match this criteria to show the first sentence though. Haha Hope this helps :D If you need help just ask away!

BTW here is the link to the string filters: https://help.shopify.com/themes/liquid/filters/string-filters#slice 

Maybe something there could help you if split does not help.

Cheers & Good luck! 

Entrepreneur, Developer, Geek, Gamer and very passionate about WEB development! :P

Need help with your Shopify Store? Contact me: jfeuchter@gmail.com :D
0 Likes
Highlighted
New Member
6 0 0

I love this - not sure why but it's forcing my products into a weird layout on the grid. I have them two up, and the first product sits alone, then the rest are stacked accordingly. I have for products listed in this test gallery to make it even. Not sure how splitting it is creating this issue (it disappears when i allow the full description)

0 Likes
Highlighted
Shopify Partner
54 9 9

I am always looking for quick simple solutions, 
This worked for me 

{{product.description | slice: 0,180}}

Fetching first 181 characters, You can change it accordingly.

If helpful then please Like & Accept Solution. | Buy me a coffee
Customizing Store or upgrading with custom functionality - Hire Me

Feel free to contact me on rrrobin@yahoo.com regarding any help regarding
Shopify Customization | Automation of Tasks | Shopify Design Changes | Shopify Custom Theme Development and Desing | Custom Functions into Shopify.
0 Likes
Highlighted
New Member
1 0 0

I used: 

 

{{ product.description | truncatewords: 20 }}

0 Likes