【发布时间】:2018-11-09 12:14:30
【问题描述】:
我有一个 get_the_content() Wordpress 代码,如下所示。我想强制代码执行以下操作:
- 不要将空标签显示为 nbsp; (现在工作)
- 只显示有限的字数(不知道如何)
我将此代码添加到我的 home.php 中:
<?php
$content = get_the_content('Read more');
$content = str_replace(' '," ", get_the_content());
$content = preg_replace( '/\s+/', ' ', $content );
echo $content;
?>
它有效,但我现在只想显示有限数量的单词。 $char_limit 和 wp_trim_words() 之类的所有解决方案都不是我要寻找的解决方案,因为它们弄乱了博客文章。
我能做什么?
【问题讨论】: