在当前主题的functions.php文件中添加函数
function word_count($cid){
$db = Typecho_Db::get ();
$rs = $db->fetchRow($db->select('table.contents.text')->from('table.contents')->where('table.contents.cid=?',$cid)->order ('table.contents.cid',Typecho_Db::SORT_ASC)->limit (1));
return mb_strlen($rs['text'], 'UTF-8');
}
在文章页面模板(通常是post.php)添加调用代码
<?php echo word_count($this->cid); ?>


没有回复内容