Last active
December 2, 2020 15:22
-
-
Save twentyfortysix/090646d6129f6ed93a609377f652b00e to your computer and use it in GitHub Desktop.
WP - manual clean timber excerpt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# beware of gallery shortcodes #} | |
{% set content = function('strip_shortcodes', item.get_preview(80,false,"",true)) %} | |
{# strip tags #} | |
{{ function("strip_tags", post.content)|truncate(50) }} | |
{{ content|striptags|truncate(50) }} | |
function custom_trim($value, $limit = 100, $end = '...'){ | |
$value = strip_tags($value); | |
if (mb_strwidth($value, 'UTF-8') <= $limit) { | |
return array($value, false); | |
} | |
return array(rtrim(mb_strimwidth($value, 0, $limit, '', 'UTF-8')).$end, true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment