14时18分 02月23日 2010年
WordPress 可自动截取字符文章摘要代码
Category: WordPress, Author: Shenai Qiu, Popularity: 28%WordPress 的文章摘要功能一般有两种实现方法,即使用 More 标记或使用插件。对于前者,方便是方便,但会缩略内容后紧随全文阅读的链接,而且 RSS 中也会输出摘要。使用插件,可良好支持中文截断的并不多见。
使用以下代码,文章摘要的可控性会更强,代码如下:
<?php echo mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 200,"……"); ?>其中,200 为自动截取字符数目限制,”……” 表示紧随缩略内容的符号。
Tags:PHP, WordPress.
评论数量(0) | Add Comments
本文网址:http://www.shenaiqiu.com/archives/wordpress/908.html

