使用字符截取来给WordPress文章增加简介

WordPress在文章列表页面,通常用文章部分内容作为简介,截取方法是在the_loop中参加函数方法:

$content = get_the_content();
$content = wp_strip_all_tags(str_replace(array('[',']'),array('<','>'),$content));
echo mb_strimwidth(strip_tags($content), 0, 230,"...");

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注