在functions.php文件”?>”前添加一下代码“
function deel_strimwidth($str ,$start , $width ,$trimmarker ){ $output = preg_replace('/^(?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,'.$start.'}((?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,'.$width.'}).*/s','1',$str); return $output.$trimmarker;} ?>
在需要显示引言的地方添加一下代码:
<?php if( !post_password_required() ){echo deel_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 150, '...');}else{echo '密码保护文章,暂无摘要!';}?>