设置自定义字符限制 WP_Query

Set character limit on custom WP_Query

我已经为此搜索了 2 天的解决方案,但 none 的答案直到现在才帮到我。

我有一个用于自定义 Wordpress 循环的 WP_Query,我只想在 the_content.

中显示不超过 100 个字符(不是单词)的帖子
<?php $movies = new WP_Query(
    array(
        'showposts' => 4,
    )
);
 if($movies->have_posts()) : while($movies->have_posts()) : $movies->the_post(); ?>

       <h2><?php the_title(); ?></h2>
       <div id="content"><?php the_content(); ?></div>

 <?php endwhile; endif; ?>

有没有我可以用作数组的核心解决方案,或者我需要想出另一种方法来做到这一点?

我怎样才能得到这些结果?

谢谢你们,你们太棒了。

试试这个

<?php $movies = new WP_Query(
    array(
        'showposts' => 4,
    )
);
 if($movies->have_posts()) : while($movies->have_posts()) : $movies->the_post(); ?>

       <?php if(strlen(get_the_content()) <= 100): ?>

       <h2><?php the_title(); ?></h2>
       <div id="content"><?php the_content(); ?></div>
    <?php endif; ?>

 <?php endwhile; endif; ?>