我不太确定我在做什么,但是在我试图在 WordPress 的自定义首页上返回 140 个多字节日文字符时,我在网上找到了自定义摘录的这段代码。可能是我没有 strip_tags 功能。如果是这样,有人可以告诉我我需要做什么才能让它工作吗?谢谢你。
front.php -
<?php
$recentPosts = new WP_Query();
$recentPosts->query('showposts=5');
?>
<?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo winexcerpt(140); ?></a></li>
<?php endwhile; ?>
</ul>
functions.php -
function winexcerpt( $length ) {
global $post;
$content = mb_substr(strip_tags($post->post_content),0,$length);
return $content;
}