Tag: 字符截取
WordPress UTF8 中文截取
UTF8 中文截取 其中对字符串预先 __() 处理,可以从 qtranslate 中取出当前语言部分然后进行截取。 function the_excerpt_max_charlength($charlength) { $excerpt = get_the_excerpt(); $charlength++; if (mb_strlen($excerpt) > $charlength) { $subex = mb_substr($excerpt, 0, $charlength – 5); $exwords = explode(‘ ‘, $subex); $excut = – ( mb_strlen($exwords[count($exwords) – 1]) ); if ($excut < 0) { echo mb_substr($subex, 0, $excut); } else { echo $subex; } echo…