wordpress文章的description自动截取文章内容前面部分做描述

中文网站:

if(is_home()||is_category()||is_tag()){
    echo  iconv('GB2312','UTF-8','杂志啦提供PDF杂志,图书,电子书免费下载,在线阅读.包括读者,摄影之友,火花,时尚,美食,家居,装修,军事,财经,人物周刊等');
}
if(is_single()){
    if (has_excerpt()) {
        echo $description = get_the_excerpt(); //文章编辑中的摘要
    }else {
        function trimall($str)
        {
            $qian = array(" ", " ", "\t", "\n", "\r");
            return str_replace($qian, '', $str);
        }
        $str = mb_strimwidth(strip_tags(apply_filters(‘the_content’, $post->post_content)), 0, 350,””);
        echo trimall($str);
    }
}

英文网站:

if(is_home()||is_category()||is_tag()){echo 'Beautiful WordPress theme/template free download';}
if(is_single()){
    $str=mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 280,"...",'utf-8');
    $quchu = array("\t", "\n", "\r");
    echo str_replace($quchu, '', $str);


}