fbpx

Black Friday Sale 50% Off

Days
Hrs
Min
Sec

Need Help?

Here are some good places you cant start.

Join the Community

Whats New?

Get updated about all the good stuff!

Truncate Filter – limit number of characters

For limiting number of characters of any text you can use the “truncate” filter in twig. 

 

The usage examples exists at the code examples. 

 

On how to enable twig enable code examples please read in this article: Enabling twig code examples

				
					{# use the truncate filter for lower the text length. arguments are: (numchars, preserve words(true|false), separator="...")#}

{{ some_attribute|truncate }}
{{ some_attribute|truncate(50) }}
{{ some_attribute|truncate(100, true) }}
{{ some_attribute|truncate(150, true, "...") }}
				
			
The second parameter: Number of characters. Default is 100
 
The third parameter – if preserve full word (true/false) . default is false. 

and the fourth parameter –  string that will be added if the text was truncated. by default is “…”
 
For example to use it in post list item you can write:
				
					<div>
  {{item.posts.content|raw|truncate(80,true)}}
 </div>
				
			

The biggest sale of the year
50% OFF all pricing plans!

Days
Hrs
Min
Sec

Download is just a click away

Get instant access to tons of Elementor goodies, completely FREE!

Hurray!

You got FREE access to the worlds leading widgets for Elementor page builder!