Php substr()无法修剪wordpress小部件中的内容()

Php substr()无法修剪wordpress小部件中的内容(),php,wordpress,Php,Wordpress,这里echo substr($content,0100)无法将内容从0裁剪到100。这位于my_theme/functions/widgets/widget portfolio posts thumbs.php中,这是因为实际输出内容。您想使用的是。试试这个: <div class="wpex-recent-posts-content clr"> <a href="<?php the_permalink(); ?>" title="<?php the_titl

这里
echo substr($content,0100)无法将内容从0裁剪到100。这位于
my_theme/functions/widgets/widget portfolio posts thumbs.php

中,这是因为实际输出内容。您想使用的是。

试试这个:

<div class="wpex-recent-posts-content clr">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a><p>
<?php
    $content = the_content();
    echo substr($content,0,100);
?>
</p>
</div>

你检查了$content吗?是打印内容吗?不错,但会更好。if(strlen($content)>25{echo substr($content,0,50)。“…”;}else{echo$content;}但是,如果您喜欢index.php页面中的这一点,并且仍然希望将readmore保持为所使用的
,该怎么办?因此,要加载一个从char 205开始的摘要,然后加载内置的char数,然后加载readmore。。
$content = get_the_content();
$content = strip_tags($content);
echo substr($content, 0, 100);