我正在重新设计我的网站,发现自己需要在侧边栏上显示帖子摘录 . the_excerpt()似乎是正确的用法,但我也在我的主要博客页面上使用摘录 . 55字的限制在我的主页上看起来不错,但不是我的侧边栏 . 我需要一种方法来限制只在我的侧边栏中的_excerpt中返回的单词 .
<div id="sidebar">
<a href="<?php the_permalink(); ?>" title="Permalink to <?php the_title(); ?>">
<?php the_title() ?>
</a>
<?php the_excerpt(); ?>
</div>
我想在侧边栏中,摘录长度限制在20个单词之内
1 回答
你可以使用substr()