这是我在我的一个网站的页脚内的代码,这基本上是3个最新的帖子和显示the_title
您可以将此更改为显示the_excerpt
.
<?php // news posts loop begins here
$newsPosts = new WP_Query(\'page=blog&posts_per_page=3\');
if ($newsPosts->have_posts()) :
while ($newsPosts->have_posts()) : $newsPosts->the_post(); ?>
<!-- Blogs -->
<div class="post-item">
<!-- This is where you can insert the excerpt -->
<h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
</div>
<!-- ./Blogs -->
<?php endwhile;
else :
// fallback no content message here
endif;
wp_reset_postdata();
?>