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:

Download is just a click away

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


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