我是wordpress主题的新手。我正在开发一个主题,但使用post_excerpt它不显示内容。
$recent_posts = wp_get_recent_posts($args);
foreach( $recent_posts as $recent ){
echo $recent[post_content];
}为什么它没有显示。但是post_content它显示的是内容。
发布于 2016-08-25 13:00:35
在WordPress循环操作中显示
帖子摘录。
假设你在帖子中的摘录部分发布了一些东西。
$recent_posts = wp_get_recent_posts($args);
print_r($recent_posts);
foreach( $recent_posts as $recent )
{
echo $recent[the_excerpt];
}这将使您能够单独显示帖子摘录。
发布于 2016-08-25 13:11:07
另一种解决方案可以是:
<?php
global $post;
$recent_posts = wp_get_recent_posts($args);
if( $recent_posts-> have_post()) : while( $recent_posts->have_post()) : $recent_posts->the_post(); ?>
<?php echo $post->post_excerpt; ?>
<?php endwhile; endif; ?>
<?php wp_reset_postdata(); ?>https://stackoverflow.com/questions/39136816
复制相似问题