首页 > Typecho 最新博客文章标题怎么截取

Typecho 最新博客文章标题怎么截取

<ul class="widget-list">
  <?php $this->widget('Widget_Contents_Post_Recent')
        ->parse('<li><i class="fa fa-angle-right"></i><a href="{permalink}">{title}</a></li>'); ?>
</ul>

title 怎么截取40个字符


谢谢,可以,但是还是有一个问题,中文标题和英文标题截取效果不一样,如何改进?网站用utf-8编码。


<ul class="widget-list">
    <?php $this->widget('Widget_Contents_Post_Recent')->to($recents); ?>
    <?php while($recents->next()): ?>
    <li>
        <i class="fa fa-angle-right"></i>
        <a href="<?php $recents->permalink(); ?>"><?php $recents->title(20); ?</a>
    </li>
    <?php endwhile; ?>
</ul>

上面是截取 20 个字

【热门文章】
【热门文章】