我已经在寻找解决方案2天了,但直到现在这些答案都没有帮助我。
我有一个自定义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; ?>
我是否可以使用任何核心解决方案作为阵列,或者我需要找到另一种方法来做到这一点?
我如何获得这些结果?
谢谢你们,你们太棒了。
答案 0 :(得分:-1)
试试这个
<?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; ?>