The truncate_html filter shortens a string to a specified length and ensures that the HTML does not get broken.
The truncate_html filter has the following signature.
The length to truncate the string to.
This argument is required.
To truncate a string to 100 characters you would do the following:
Since HTML is preserved, the number of characters may not be exactly the number of characters submitted but it will be very close.
If the string is less than the number of characters specified then no truncation occurs.
The character to append to the end of the truncated string.
By default the character is … "…". If a value is not passed then the default character is used.
As with all filters, you can use the filter when assigning a value to another variable.